Hi there i have convert angular 17 project into android app by using capacitor, and i want that app can connect to my local iis server which will be in same network. i have made provision to set iis server IP address on login page as SetURL button, but still app not connecting to iis server. but when i tried same connection from mobile chrome browser it got connected …please help me out for this issue.
i have make changes in capacitor.config.ts file as follows.
server:{
hostname: ‘com.example.app’,
allowNavigation:[‘*’],
cleartext:true,
}
You need to explain some more what you are trying to do. Are you making API calls to this IIS server?
Yes…i have deployed dotnet core API on iis and im trying to access it through angular application. it works when i;m calling those api through angular app (chrome browser), but as soon as i convert that application into apk file that application is not able to connect…
Is the API endpoint HTTP or HTTPS? By default, Android blocks HTTP requests.
Ok…its HTTP only…let me check with https…
If you have to use HTTP, you can create an exception using network_security_config.xml
. See Unable to carryout HTTP post on Android - #2 by twestrick
I have tried by changing HTTPS but still…android app not connecting.
Have you checked for errors? You can use DevTools by going to chrome://inspect/#devices in Chrome. Also check LogCat in Android Studio. It could be a CORS issue.
Hey …This is the logCat i’m getting after sending request to iis through apk,
app_time_stats: avg=602.56ms min=311.05ms max=894.07ms count=2
app_time_stats: avg=127.82ms min=31.36ms max=299.85ms count=8
File: https://com.example.app/polyfills-N6LQB2YD.js - Line 2 - Msg: Mixed Content: The page at ‘https://com.example.app/login’ was loaded over HTTPS, but requested an insecure resource ‘http://192.168.0.100:44393/api/UserListDropDown’. This request has been blocked; the content must be served over HTTPS.
File: https://com.example.app/main-65ALYUFO.js - Line 71 - Msg: this is client side error [object Object]
app_time_stats: avg=125.51ms min=49.62ms max=190.50ms count=8
Autofill is disabled: AutofillManager isn’t available in given Context.
app_time_stats: avg=195.96ms min=36.62ms max=853.52ms count=7
Davey! duration=935ms; Flags=0, FrameTimelineVsyncId=80721, IntendedVsync=950990130842, Vsync=951006797508, InputEventId=0, HandleInputStart=951008648600, AnimationStart=951008727300, PerformTraversalsStart=951380655300, DrawStart=951381080000, FrameDeadline=951073464172, FrameInterval=951008573500, FrameStartTime=16666666, SyncQueued=951381871700, SyncStart=951382412600, IssueDrawCommandsStart=951382480800, SwapBuffers=951841200100, FrameCompleted=951926470100, DequeueBufferDuration=643100, QueueBufferDuration=6621900, GpuCompleted=951926470100, SwapBuffersCompleted=951907917900, DisplayPresentTime=0, CommandSubmissionCompleted=951841200100,
app_time_stats: avg=84.13ms min=35.52ms max=168.72ms count=13
This is the xml file ‘network-security-config’
<?xml version="1.0" encoding="utf-8"?>
localhost
com.example.app
what we can do next…
No idea what you are trying to say here but appears you didn’t follow Unable to carryout HTTP post on Android - #2 by twestrick
Your network_security_config.xml
should look like this:
<?xml version="1.0" encoding="utf-8" ?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain>192.168.0.100</domain>
</domain-config>
</network-security-config>
Then make sure that config file is registered in your AndroidManifest.xml
file.
Hi sorry if i missed any thing in reply…now below i’m sharing all the files related to this issue.
This is the - network-security-config
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">192.168.0.100</domain>
</domain-config>
I have mension into android.menifeast.xml file
android:networkSecurityConfig=“@xml/network_security_config”
but still apk file not able to connect to iis server.
Not sure. You could try setting server -> androidScheme
to http
in your Capacitor config just to see if that works.
Hurrey…
, it works and now i can connect to iis through apk app. thanks a lot for you valuable time and support. Thanks…twestrick
1 Like