Hello. 小an i disable CORS check on android?
"cordova-android": "^8.0.0",
"cordova-plugin-ionic-webview": "^4.1.2",
WebView in io.myapp (74.0.3729.149)
Access to XMLHttpRequest at 'https://replaced-domain.org/...' from origin 'http://localhost' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://www.replaced-domain.org' that is not equal to the supplied origin.
Can I use a non-IonicWebView engine and default?
same here. cordova-android:8.1.0 in my earlier app which used cordova-android 7, this problem was not present.
Solved it temporarily by editing the cordova-plugin-ionic-webview\src\android\com\ionicframework\cordova\webview\WebViewLocalServer.java file.
Add the following:
Line 108: tempResponseHeaders.put("Access-Control-Allow-Origin", "*");
Line 262: tempResponseHeaders.put("Access-Control-Allow-Origin", "*");
remove the android platform and add the android platform. After running/compiling, the above java file will be copied from plugins to platforms and the error will go away.
### OR ###
You can do something like this in pure js format:
let imagePath:SafeResourceUrl = this.domSanitizer.bypassSecurityTrustUrl(
this.di.webview.convertFileSrc(photoURL)
);
let image = imagePath['changingThisBreaksApplicationSecurity'];
set image variable as the src of the img tag.
@gaurav-chandra Thanks!
But after adding the headers all requests stopped running.
net::ERR_INTERNET_DISCONNECTED
No other errors during build or in console.
+1 I would like to be able to disable CORS check
it's not possible to disable CORS on the webview, you have to properly configure the server or use a native http plugin
Most helpful comment
+1 I would like to be able to disable CORS check