Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS issue with cordova-plugin-ionic-webview2.x in Ionic4 #229

Closed
zcd0000 opened this issue Nov 29, 2018 · 4 comments
Closed

CORS issue with cordova-plugin-ionic-webview2.x in Ionic4 #229

zcd0000 opened this issue Nov 29, 2018 · 4 comments

Comments

@zcd0000
Copy link

zcd0000 commented Nov 29, 2018

Ionic Info

Ionic:

   ionic (Ionic CLI)             : 4.4.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-beta.16
   @angular-devkit/build-angular : 0.10.7
   @angular-devkit/schematics    : 0.7.5
   @angular/cli                  : 7.0.7
   @ionic/angular-toolkit        : 1.2.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 ([email protected])
   Cordova Platforms     : android 7.1.4, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.0.3, (and 4 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/cundongzhang/Library/Android/sdk)
   ios-deploy        : 1.9.4
   NodeJS            : v8.12.0 (/usr/local/bin/node)
   npm               : 6.4.1
   OS                : macOS
   Xcode             : Xcode 10.1 Build version 10B61

Issues Descriptions

I have installed Nginx reverse proxy server on my computer and configured it to allow CORS.
When my application is opened in Chrome on mac, it can normally finish CORS request without any issues .
But when I deploy it to android device by "cordova run android" command, my application running in ionic-webview doesn't work because of CORS issue. Ionic-webview can normally send "options"
request to my Nginx server, but it has no next response to my server normal "options" response.
The below screenshot displays the network request and response from my device to Nginx server.

wx20181129-162758 2x

The below screenshot is my Nginx server config in nginx.conf file.

wx20181129-181701 2x

@troyanskiy
Copy link
Contributor

Hello @zcd0000
Try to test that #227

Thanks!

@zcd0000
Copy link
Author

zcd0000 commented Dec 7, 2018

I found the issue caused by the configuration of add_header 'Access-Control-Allow-Headers' * not work when CORS request is from cordova-plugin-ionic-webview. I must list all header types in this configuration just as the below, that's ok.
add_header 'Access-Control-Allow-Headers' 'Authorization, Expires, Pragma, DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';

@zcd0000 zcd0000 closed this as completed Dec 7, 2018
@rushabhmakwana-multidots

@zcd0000 Did you get any solution for this issue?

@yigonglitech
Copy link

@zcd0000 Did you get any solution for this issue?

I found the issue caused by the configuration of add_header 'Access-Control-Allow-Headers' * not work when CORS request is from cordova-plugin-ionic-webview. I must list all header types in this configuration just as the below, that's ok.
add_header 'Access-Control-Allow-Headers' 'Authorization, Expires, Pragma, DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants