fix(clerk-js): Prevent duplicate __client_uat cookies in iframe contexts#7875
fix(clerk-js): Prevent duplicate __client_uat cookies in iframe contexts#7875
Conversation
When an app is loaded in both an iframe and a standalone tab, getCookieDomain() returns undefined in the iframe (eTLD+1 probe fails due to third-party cookie restrictions), causing host-only cookies that conflict with domain-scoped cookies from the non-iframe context. Fall back to hostname instead of undefined so the cookie set either matches the non-iframe's domain-scoped cookie or silently fails. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: e4b2d6f The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds a changeset entry for a patch release and updates getCookieDomain() in clerk-js to return the provided hostname when eTLD+1 detection fails instead of returning undefined. The change ensures a deterministic fallback for cookie domain determination and includes an updated test that expects the hostname fallback. The changes address the __client_uat cookie being set across two domain scopes when the app loads in iframe and non-iframe contexts. 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Summary
getCookieDomain()returnsundefinedin the iframe because the eTLD+1 test cookie probe fails (third-party cookie restrictions prevent domain cookies from sticking)clientUat.tsto set host-only cookies (noDomainattribute) in the iframe, while the non-iframe context sets domain-scoped cookies (withDomainattribute)__client_uatentries with conflicting valuesgetCookieDomain()now falls back tohostnameinstead ofundefined, so the cookieset()either matches the non-iframe's domain-scoped cookie (common on platforms like Replit where hostname == eTLD+1) or silently fails — both preferable to creating a conflicting host-only cookieTest plan
getCookieDomainto reflect new fallback behavior__client_uatcookies are created (no host-only duplicates)🤖 Generated with Claude Code
Summary by CodeRabbit