ionic-frameworkcorswkwebviewios13ionic-v1

CORS | Request header field Authorization is not allowed by Access-Control-Allow-Headers ionic | IOS 13 preflight response


I have migrate my IOS ionic v1 app to IOS 13 and xcode 11.5. when I install the app and try to login first time then I am able to login successfully. But when I kill the app and try to open the app then it wont allow me to auto login. My service in deployed into IIS.

In the config.xml have added these settings

<preference name="WKSuspendInBackground" value="false" />
<preference name="iosScheme" value="httpsionic" />
<allow-navigation href="httpsionic://*" />
<allow-navigation href="http://localhost:8100/*" />

when i try to open the app after killing the app from task manager. it wont allow me to login. Its giving me an error

Request header field Authorization is not allowed by Access-Control-Allow-Headers.

First Time run when I install the app work as expected :-

enter image description here

after killing the app and open it again :- enter image description here

this is the console log enter image description here

Please let me know what I am missing something here so that access the app without this above CORS error. this is my ionic info

Ionic:
   Ionic CLI         : 5.3.0
   Ionic Framework   : ionic1 1.2.4
   @ionic/v1-toolkit : 2.0.11

Cordova:
   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-webview 5.0.0, (and 18 other plugins)

Utility:
   cordova-res : not installed
   native-run  : 0.2.8 (update available: 1.0.0)

System:
   ios-deploy : 1.9.0
   ios-sim    : 8.0.2
   NodeJS     : v10.16.3 (/usr/local/bin/node)
   npm        : 6.9.0
   OS         : macOS Catalina
   Xcode      : Xcode 11.5 Build version 11E608c

Solution

  • I did not get any solution for IIS

    It might be helpful for someone how is facing this issue. So I have migrated my service to azure web apps. and all CORS issues are resolved using below command. In azure I am able to add Custom Origins after running these command from terminal.

    To do this:

    1. Open Terminal in your Mac
    2. Run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    3. Once that is finished: brew update && brew install azure-cli
    4. Then login with your credentials by running: az login.  this will ask you to open a website to authorize your device https://aka.ms/devicelogin
    5. Then run the azure CLI command for your specific app (this is an example of my app): az webapp cors add --allowed-origins ionic://***.com --name *** --resource-group ***

    References:

    HOWTO install Azure CLI: https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-macos?view=azure-cli-latest Configure CORS with Azure CLI: https://learn.microsoft.com/en-us/cli/azure/webapp/cors?view=azure-cli-latest#az-webapp-cors-add

    Note :- Most welcome, if someone found the solution of IIS please post here add link for reference.