-
Notifications
You must be signed in to change notification settings - Fork 1k
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
bug: 3rd party cookies not working on capacitor iOS #6302
Comments
@gabides When we ran into this problem ( Januari 2022, close to the release of ionic 6 ) This was still a big issue because iOS didnt allow saving the cookies from 3rd party cookies. Multiple issues were on at that moment, (I am reacting cause I am also curious if this is done nowadays). One of the issues was that cookie setting was done async (talking about capacitor) and therefor could not be guaranteed to be ready at time of using the other requests. (This is all old information). As changing the localhost was not recommended, we went ahead and did it anyway (I know there are things like geolocation and media functions that have issues with it, but we didn't use them.
with Just sharing what we produced back then, wondering if it is not the case any more :) |
You can also add this to your
This way you have default hostname in iOS, but it deletes on Android. Do note that I heard that in the future Android also plans to put these same restrictions for cookies that Apple does. |
Thanks for that one, yeah back when I wrote that pipeline our configs where json based. |
I can confirm this is not working as advertised in Capacitor 5.0.4 and iOS 14. Hacking
But this is not recommended. Leaving it as I'm sure the above workarounds (hack a script to replace
This can be applied as instructed here https://capacitorjs.com/docs/ios/viewcontroller A real fix would be really appreciated! |
We are facing the same problem. We use a Session-Cookie which gets issued by our backend running on a custom domain which should be appended on any subsequent requests. Our WebView is running on localhost and the option to change it to the backend URL is not feasible, because we are relying on other secure APIs (like UserMedia). We use the following settings:
Third party cookies seems to not get appended, although the docs seem to imply that (though they are not very detailed) The only thing that helps is adding the NSCrossWebsiteTrackingUsageDescription to the Info.plist and allowing tracking in the iOS settings for our app. But this is of course not a suitable production solution. Is there any other way we can get our third party cookie appended? Update: |
We're facing the same issue. Any news on this? |
Hello, guys, same behavior here:
However, the Are we missing something else? 🤔 |
With your solution we keep getting capacitor://mydomain Any update on this ?¿ |
@jonatato don't know what to tell you. The above solution is still working for me on Capacitor 5.7.2. Perhaps your ViewController isn't hooked up correctly? |
Just as further information: After testing, I can confirm that only the Alternative configurations for enabling 3rd party cookies ( As previously mentioned, the documentation suggests that enabling this feature should result in the attachment of third-party cookies 🤔 Let's see if somebody from the team can provide more information about this topic 🙏 |
Running into the same issue. Setting Setting |
Setting the hostname makes the app think its that site. Doing this makes
the cookie not "thirdparty" anymore. Because the cookie was issued for
api.example.com, and the hostname is also api.example.com. Keep in mind
this only works for iOS, on android XHR calls will fail because it tries to
resolve your requests against the device itself.
…On Mon, 15 Apr 2024, 23:29 Anton Begehr, ***@***.***> wrote:
Running into the same issue. Setting WKAppBoundDomains doesn't seem to be
enough to allow cookies from a third-party domain. I'm using an iframe
(that points to a remote url) in a capacitor app to show some content that
requires setting cookies and it fails even though I have added the domain
to WKAppBoundDomains as per the docs.
Setting "server": { "hostname": "…" } actually seems to work! However, I
don't understand what it does and why it would work. Also it takes only one
value, so this will be a problem with multiple third-party cookie domains.
—
Reply to this email directly, view it on GitHub
<#6302 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYH27JO2MFMDRVQRONB6GDY5RBCTAVCNFSM6AAAAAAU6I34S2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJXHA2DCNJUGA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Thanks for explaining, @Webrow! |
I never used my live reload on an iOS device, we usually develop web-based and then do the testing on the mobile devices. |
We're aiming to migrate our application to Capacitor view-by-view and using iframes to show distinct pages of the legacy app, so it's not really 3rd party cookies however they will always be handled as third party, as the app normally runs on localhost, so to the client they are 3rd party. |
Bug Report
Capacitor Version
Platform(s)
ios
Current Behavior
When setting CapacitorConfig.server.hostname to
localhost
in capacitor config (default value, recommended to keep it that way in the doc), 3rd party cookies are not working.other settings:
CapacitorConfig.ios.limitsNavigationsToAppBoundDomains: true
localhost
+ 3rd party domain in Info.plist > WKAppBoundDomainsThe doc of capacitor cookies suggest that 3rd party cookies are supposed to work
https://capacitorjs.com/docs/apis/cookies#third-party-cookies-on-ios
Expected Behavior
3rd party cookies should be set and used correctly by the capacitor webview
Code Reproduction
hard to create a reproduction setup as it involves a backend service sending cookies to set
The text was updated successfully, but these errors were encountered: