Ionic Cordova - CORS issue - how to fix?

-2

I have tried the suggstions on these answers but no luck:

CORS + Cordova : issues with : Access-Control-Allow-Origin

Access-Control-Allow-Origin Error..(using cordova)

cordova requirements

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-29,android-28,android-27
Gradle: installed C:\Gradle\gradle-5.3.1\bin\gradle

node -v
10.19.0

cordova -v
8.1.2

ionic -v
4.10.3

Galaxy S9
Android 10
WebView Chrome 80+

I am writing an app with Cordova, Ionic v1, and AngularJS 1.5

In the past everything was working fine but now I am getting a CORS issue.

I notice that there are 2 Access-Control-Allow-Origin values in the header.

What could be causing this problem and how can I fix it?

Cross-Origin Read Blocking (CORB) blocked cross-origin response 'our url' with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

Access to XMLHttpRequest at 'https://our url' from origin 'http://localhost' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'http://localhost, *', but only one is allowed.


'our url'
Request Method: GET
Status Code: 200 OK
Remote Address: 52.169.191.40:443
Referrer Policy: no-referrer-when-downgrade


Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Origin: http://localhost
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: x-sw-reg-server-environment
Cache-Control: no-cache
ClientEndpoint: myurl
ClientLastModified: 2020-03-27T15:25:59.1500000
Content-Encoding: gzip
Content-Length: 445
Content-Type: application/json; charset=utf-8
Date: Tue, 07 Apr 2020 09:53:41 GMT
Expires: -1
Pragma: no-cache
Server: Microsoft-IIS/10.0
Set-Cookie: ARRAffinity=f9cd5cd5c52295298edba00574d1791041f91f8c214f4c71c380c68ab83d2634;Path=/;HttpOnly;Domain=myurl
Vary: Accept-Encoding
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
x-sw-reg-server-environment: unknown environment (Azure Environment AppSettings not set)

config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget android-versionCode="400019050" id="my.app" version="4.19.5" windows-packageVersion="4.19.5.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>my app</name>
    <description>my app</description>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="*" />
    <preference name="LoadUrlTimeoutValue" value="70000" />
    <preference name="webviewbounce" value="false" />
    <preference name="UIWebViewBounce" value="false" />
    <preference name="DisallowOverscroll" value="true" />
    <preference name="android-minSdkVersion" value="19" />
    <preference name="android-targetSdkVersion" value="28" />
    <preference name="BackupWebStorage" value="local" />
    <preference name="AutoHideSplashScreen" value="false" />
    <preference name="FadeSplashScreen" value="true" />
    <preference name="ShowSplashScreenSpinner" value="false" />
    <preference name="StatusBarOverlaysWebView" value="false" />
    <preference name="StatusBarBackgroundColor" value="#14579F" />
    <preference name="StatusBarStyle" value="lightcontent" />
    <preference name="android-build-tool" value="gradle" />
    <preference name="Orientation" value="portrait" />
    <platform name="android">
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
        <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
        <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
        <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
        <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
        <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
    </platform>
    <platform name="ios">
        <config-file overwrite="true" parent="NSCalendarsUsageDescription" target="*-Info.plist">
            <string>The app would like to create a calendar event.</string>
        </config-file>
        <config-file overwrite="true" parent="NSPhotoLibraryUsageDescription" target="*-Info.plist">
            <string>Used to store employee photo.</string>
        </config-file>
        <config-file overwrite="true" parent="NSBluetoothPeripheralUsageDescription" target="*-Info.plist">
            <string>Bluetooth is not used in the app but there is a plugin that has bluetooth capabilities that is not being used.</string>
        </config-file>
        <config-file overwrite="true" parent="NSBluetoothAlwaysUsageDescription" target="*-Info.plist">
            <string>Bluetooth is not used in the app but there is a plugin that has bluetooth capabilities that is not being used.</string>
        </config-file>
        <config-file overwrite="true" parent="NSMicrophoneUsageDescription" target="*-Info.plist">
            <string>The app would like use the microphone.</string>
        </config-file>
        <config-file overwrite="true" parent="NSLocationAlwaysUsageDescription" target="*-Info.plist">
            <string>The app tries to get the location while it's running.</string>
        </config-file>
        <config-file overwrite="true" parent="NSCameraUsageDescription" target="*-Info.plist">
            <string>Used to upload employee photo.</string>
        </config-file>
        <config-file overwrite="true" parent="NSLocationWhenInUseUsageDescription" target="*-Info.plist">
            <string>The app uses the location for geoclocking when the user clocks on the app.</string>
        </config-file>
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2xiphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
    </platform>
    <platform name="windows">
        <icon src="resources/windows/images/Badge/BadgeLogo.png" target="BadgeLogo" />
        <icon src="resources/windows/images/AppList/Square44x44Logo.png" target="Square44x44Logo" />
        <icon src="resources/windows/images/Store/StoreLogo.png" target="StoreLogo" />
        <icon src="resources/windows/images/Small/Small71x71Logo.png" target="Square71x71Logo" />
        <icon src="resources/windows/images/Medium/Medium150x150Logo.png" target="Square150x150Logo" />
        <icon src="resources/windows/images/Large/Large310x310Logo.png" target="Square310x310Logo" />
        <icon src="resources/windows/images/Wide/Wide310x150Logo.png" target="Wide310x150Logo" />
        <splash src="resources/windows/images/SplashScreen/SplashScreen.png" target="SplashScreen" />
        <splash src="resources/windows/images/SplashScreen/SplashScreenPhone.png" target="SplashScreenPhone" />
        <preference name="BackgroundColor" value="0xffffffff" />
        <preference name="SplashScreenBackgroundColor" value="0xffffffff" />
    </platform>
    <feature name="StatusBar">
        <param name="ios-package" onload="true" value="CDVStatusBar" />
    </feature>
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreenDelay" value="3000" />
    <allow-navigation href="http://192.168.17.125:8100" />
    <plugin name="cordova-plugin-splashscreen" spec="^5.0.1" />
    <plugin name="cordova-plugin-statusbar" spec="^2.4.1" />
    <plugin name="cordova-plugin-device" spec="^2.0.1" />
    <plugin name="cordova-plugin-settings-hook" spec="^0.2.7" />
    <plugin name="cordova-plugin-save-image" spec="^0.3.0" />
    <plugin name="cordova-plugin-file" spec="^6.0.1" />
    <plugin name="cordova-plugin-file-transfer" spec="^1.7.1" />
    <plugin name="cordova-plugin-network-information" spec="^2.0.1" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
    <plugin name="cordova-plugin-inappbrowser" spec="^3.0.0" />
    <plugin name="cordova-plugin-safariviewcontroller" spec="^1.5.4" />
    <plugin name="cordova-plugin-compat" spec="^1.2.0" />
    <plugin name="cordova-plugin-camera" spec="^4.0.3" />
    <plugin name="cordova-plugin-geolocation" spec="^4.0.1" />
    <plugin name="cordova.plugins.diagnostic" spec="^4.0.12">
        <variable name="ANDROID_SUPPORT_VERSION" value="28.+" />
    </plugin>
    <engine name="windows" spec="^4.4.3" />
    <engine name="browser" spec="^5.0.4" />
    <engine name="ios" spec="5.0.1" />
    <engine name="android" spec="8.1.0" />
</widget>
cordova
http
ionic-framework
webview
cors
asked on Stack Overflow Apr 7, 2020 by user1261710 • edited Apr 7, 2020 by user1261710

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0