Replies: 3 comments 4 replies
-
Can you provide an example of how you're setting the cookie (in the raw HTTP form). This should be discoverable if you can hit your API using a non-browser based HTTP client (e.g. Postman, NodeJS, etc...) and inspecting the HTTP response header. At a basic level, it should contain something like:
I'm not as sure with iOS but Chrome has changed the default behaviour around how cookies are sent/received in regards to cross origin request. The cooke has a
I believe if you want cookies to be sent to cross-origin domains (which will always be the case for Cordova/Hybrid WebView apps) the server must configure the cookie with 2 options:
The So a full example would look like:
I don't use cookies in my day-to-day work, so all of this information is just gathered from helping others with similar problems or aggregating documentation. I've never actually used any of this in practice. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response! My cookies are set with secure: httpOnly flag. I will try setting the flags you recommended, but that will have potential security impacts, especially on my web app , which will use the same APIs as the mobile apps will. That is way I still believe a reverse proxy is better for this scenario. these are my cookies:
You are saying that a proxy can be potentially called by other apps, but then how the static resources are served and secured at the cordova level? as they should be served by some kind of web server too. What if a dedicated context path (lets say localhost/proxy/....) will be allocated at this resource web server level, to proxy the requests to the user configured http servers ? This configuration to be done by the users, potentially in the config.xml. An embedded reverse proxy will remove all the problems with CORS in Cordova, for which there are more questions than actual answers. |
Beta Was this translation helpful? Give feedback.
-
@breautek I've set the cookie flags on the server side, the way you mentioned but the Cordova app still doesn't work. Plus the web app stopped working too, because of these changes :) This is how the server returned cookie looks like after the changes.
On the subsequent requests, this cookie is not being passed, from what I can see in the chrome network tab. |
Beta Was this translation helpful? Give feedback.
-
Can anyone please tell me what is the best way to deal with the CORS requests and their associated httpOnly session cookies in Cordova?
I'm not finding anything clear googling around, I can only find workarounds and some references to some plugins which seem to partially works in specific configurations.
In my opinion, the best way to deal with these problems would be an embedded Cordova http reverse proxy, but I'm not able to find anything related to such a component, within Cordova. In google, I've found 2 plugins that partially seem to do that, but the android one (cordova-plugin-http-proxy) seems to be dead for a while and from what I can tell looking at the code, only handles Post and Get, while the second one (cordova-plugin-webview-proxy) is only for IOS.
Please advice.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions