-
Notifications
You must be signed in to change notification settings - Fork 396
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
Two Origins not ideal for CORS header #255
Comments
I had same problem on dotnet https://stackoverflow.com/questions/54091699/aspnetcore-2-2-api-cors-policy/54092857#54092857 |
@AMerkuri Thanks. I can set multiple origins but Android does not accept a header with with two origins. |
Do not use *. Read origin request header from the client and set Access-Control-Allow-Origin value to that. |
This is not a solution for. The server reads the header from a static configuration.
I don't want to allow any origin, either. Just the Ionic App.
|
Well, this depends entirely on your server as there are a lot of types of servers and each one is configured in a different way. |
Thanks. I cannot change the header programmtically in this case. The solution I did for now is to disable the webserver on Android. Is this worth a PR or is it unlikely to be merged? I just need this plugin for WKWebView for now and I don't know why the http protocol is necessary on Android. |
I don't think it will be merged |
The http routing is for Ionic 4 with Angular routing correct? Serving from I would like to have the option for one origin for both platforms. It was possible with version 2.3.x. Two different origins cause extra headache for developers and may be impossible for certain servers. |
Yeah, using ionic:// is technically possible, but have some problems like not being able to use getUsermedia, geolocation and some other features that require https or localhost. We might consider making the scheme configurable so people can use what suits best for them. |
Thank you. I was not aware of these limitations.
Sounds perfect. I will try that out, too. |
Hi, Still thinking how to manage this in a clean way: if(isset($_SERVER['HTTP_ORIGIN']) && preg_match('/^(http|ionic):\/\/localhost(:)?(\d+)?$/', $_SERVER['HTTP_ORIGIN'], $matches)) {
header("Access-Control-Allow-Origin: {$matches[0]}");
} As far as I have tested origin seems to be: |
# [3.1.0](v3.0.0...v3.1.0) (2019-01-17) ### Bug Fixes * **ios:** Fix video playback of files with uppercase extension ([#264](#264)) ([2c4b225](2c4b225)), closes [#260](#260) * Set engines to require Cordova CLI 7.1.0 or newer ([#276](#276)) ([40f42e1](40f42e1)), closes [#263](#263) * Use a single scheme for all files ([#270](#270)) ([3d1bcdd](3d1bcdd)), closes [#258](#258) ### Features * **Android:** Make app Scheme configurable with a preference ([#274](#274)) ([18d9f2c](18d9f2c)), closes [#269](#269) [#255](#255)
Now on 3.1.0 you can configure the Scheme for Android using this preference |
Since version 3.0.0 this plugin now uses
ionic://localhost
for iOS andhttp://localhost
for Android. TheAccess-Control-Allow-Origin
header only allows one value? Using*
is not possible for requests with credentials.What can we do about that?
The text was updated successfully, but these errors were encountered: