When running capacitor for android,
GET requests to my API aren't working, and I am getting weird headers (Client-Via:shouldInterceptRequest
) as well as the fact that the request is served from disk cache.
also the request is having incorrect Content-Type
of Content-Type:text/html
instead of JSON
Using capacitor ionic V1.0.0
While running the request from the browser, or capacitor IOS it's working totally fine and the request is being served from the network as well with the correct headers.
Any idea of why my webview requests are being intercepted like this? Thanks.
Managed to find the solution, and decided to post the question & answer for others to come across this issue.
The root cause was that my server URL was also in my capacitor.config.json
under the allowNavigation
config.
Thus GET requests were intercepted by capacitor.
Removing my server URL from allowNavigation
solved the issue.
before:
{
"appId": "app.com",
"appName": "app",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "dist",
"server": {
"allowNavigation": [
"my-server-url.com",
]
},
"android": {
"allowMixedContent": true
}
}
the corrected config:
{
"appId": "app.com",
"appName": "app",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "dist",
"server": {
"allowNavigation": []
},
"android": {
"allowMixedContent": true
}
}