android: xhr GET request aren't working if your server URL is in `allowNavigation` config
See original GitHub issueDescription of the problem:
Having your server URL in allowNavigation
, won’t allow you to make simple GET xhr requests on android.
Because capacitor will intercept them as navigation requests.
Affected platform
- Android
- iOS
- electron
- web
OS of the development machine
- Windows
- macOS
- linux
When my API URL is being added to the allowNavigation
config.
E.G
{
"appId": "app.com",
"appName": "app",
"bundledWebRuntime": false,
"npmClient": "npm",
"webDir": "dist",
"server": {
"allowNavigation": [
"my-server-url.com",
]
},
"android": {
"allowMixedContent": true
}
}
When my app is having a GET endpoint of my server.
Calling it VIA regular browser or IOS returns the proper headers and response.
But on android webView, capticator intercepts the request.
note the served from disk cache
and Content-Type:text/html
, Client-Via:shouldInterceptRequest
headers.
In browsers or IOS the response returns the correct content-type which is application/json;
Capacitor version: 1.0.0 node version: v8.11.3 npm version: 6.9.0 CocoaPods version:
Steps to reproduce:
- Have any API with a GET request.
- Add the API url to
allowNavigation
config. - run and build andorid project with an XHR request to the server.
I wonder if capacitor could differentiate between XHR requests and navigation requests to address this issue.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (8 by maintainers)
Top GitHub Comments
thanks for the sample project, but it was already fixed in https://github.com/ionic-team/capacitor/pull/2146
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.