You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm trying to build an app with Ionic Capacitor and have now a problem with cookies. I think this is a trivial problem by building a Capacitor app with cookies. So I ask for help here. You are here all Capacitor experts ;)
The app should use cookie for user to login. Let's say the server is example.com and the app in Capacitor WebView is hosted under myapp.example.com (by changing 'server --> hostname' in capacitor.config.json).
The problem is, when I fired a xhr-request from the app to the server, the Set-Cookie header in the response is not accepted. Here is an example of request and response:
Access-Control-Allow-Methods: GET, POST, DELETE, PUT, OPTIONS, HEAD
Access-Control-Allow-Origin: *
Set-Cookie: a=something; Domain=example.com; Path=/; HttpOnly; Secure
X-Frame-Options: sameorigin
How can I get the cookie accepted in WebView? Which headers should actually be set (Access-Control-Allow-*, Set-Cookie, etc.)? Is there any other special settings in the xhr-request what I am missing?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm trying to build an app with Ionic Capacitor and have now a problem with cookies. I think this is a trivial problem by building a Capacitor app with cookies. So I ask for help here. You are here all Capacitor experts ;)
The app should use cookie for user to login. Let's say the server is
example.com
and the app in Capacitor WebView is hosted undermyapp.example.com
(by changing 'server --> hostname' incapacitor.config.json
).The problem is, when I fired a xhr-request from the app to the server, the
Set-Cookie
header in the response is not accepted. Here is an example of request and response:Request:
Response:
How can I get the cookie accepted in WebView? Which headers should actually be set (Access-Control-Allow-*, Set-Cookie, etc.)? Is there any other special settings in the xhr-request what I am missing?
Beta Was this translation helpful? Give feedback.
All reactions