Cookies blocked after capacitor 4 upgrade

I have been using capacitor with a nuxt 2 app for sometime. Using the nuxt axios plugin to make xhr requests to my api. When I initially set this up I had to make sure my api in development was using SSL. Didn’t have any other issues on android or ios.

After upgrading to capacitor 4 I am having issues. Been testing it on android and everything works fine in the emulator. As soon as I deploy to my actual phone (pixel 6 pro) the session cookies get blocked. Nothing shows up in the console to explain why. It just shows a triangle next to the cookie set showing it is getting blocked for some reason.

I tried changing the server hostname in the config to something on the same domain as the api server instead of localhost. That made no difference.

Any ideas what has changed with the new release that would cause cookies to get blocked?

Seemed to be something with changing to Sdk 31+ and samesite. Solution I found was to add to my capacitor.confg

  "server": {
    "iosScheme": "https",
    "androidScheme": "https",
    "hostname": "app.mydomain.com"
  }
1 Like

Thanks for coming back and sharing your answer!

One important side effect of this change that I wanted to quickly call out for anyone using this is that changing the hostname from the default of localhost affects the use of Web APIs that would otherwise require a secure context such as navigator.geolocation and MediaDevices.getUserMedia. Be sure to test this type of functionality after making the change as it may be required to use the native equivalents of functionality such as these. This may or may not affect you, but it can catch you unaware if you didn’t know about that! :smile: