http icon indicating copy to clipboard operation
http copied to clipboard

iOS cookies

Open diegoanso opened this issue 3 years ago • 5 comments

Hi, I am using this plugin(capacitor-community-http) in a framework7 application with capacitorJs and Vuejs. For the API I am using Laravel Sanctum (all this in local host). I am trying to use the cookie authentication which first call the endpoint /sanctum/csrf-cookie, the answer should run the Set-Cookie and store the csrf token as a cookie on the browser. On the web everything works as expected saving the cookies but on IOS for some reason is not saving the cookies so my future requests don’t include the csrf token and can’t access the api.

I have tried to include the domain in the info.plist, adding the webfetch include credentials, changing host name in the config, etc. I have tried a lot so far but can’t get it to work.

Does someone have an example of how they achieve this or have any idea why it might not be working on IOS ?

diegoanso avatar Feb 18 '22 00:02 diegoanso

Hello, I have the same problem with Ionic (Angular, Capacitor). It works on Android but not on IOS.

Someone has a workaround ? Thanks

laurentguenver-a avatar Mar 22 '22 09:03 laurentguenver-a

Also having trouble getting cookies working. Any solutions here?

billpull avatar Apr 26 '22 14:04 billpull

Same here, using Ionic (Vuejs, Capacitor) and JWT Auth. It's working with Firefox ionic serve but not on iOs inside app. I get an obsolete Token 401 error.

mikmikmik avatar Jun 29 '22 15:06 mikmikmik

@mikmikmik for the most part I got cookies working with making a few changes to my headers and calling get/set cookie probably more than needed. Can check out my SO post here.

https://stackoverflow.com/questions/72045698/capacitor-ios-using-cookie-based-auth

billpull avatar Jun 29 '22 15:06 billpull

@billpull thanks I'll have a look. My problem is a bit different it's about the refresh_token cookie.

mikmikmik avatar Jun 29 '22 15:06 mikmikmik