fix(backend): Fix issue with FAPI suffixed cookies disabled - #3789
Conversation
For production instances that use the latest ClerkJS and backend SDKs if the FAPI suffixed cookies are disabled, in every page refresh a handshake is triggered. To fix this we should use the un-suffixed cookies when the suffixed client_uat does not exist but the suffixed session exists.
🦋 Changeset detectedLatest commit: d8bdf84 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 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 |
|
!snapshot |
|
Hey @dimkl - the snapshot version command generated the following package versions:
Tip: Use the snippet copy button below to quickly install the required packages. npm i @clerk/astro@1.0.2-snapshot.v22b1fc0 --save-exact
npm i @clerk/backend@1.4.1-snapshot.v22b1fc0 --save-exact
npm i @clerk/chrome-extension@1.1.6-snapshot.v22b1fc0 --save-exact
npm i @clerk/clerk-js@5.10.1-snapshot.v22b1fc0 --save-exact
npm i @clerk/clerk-expo@1.2.9-snapshot.v22b1fc0 --save-exact
npm i @clerk/express@0.0.19-snapshot.v22b1fc0 --save-exact
npm i @clerk/fastify@1.0.21-snapshot.v22b1fc0 --save-exact
npm i gatsby-plugin-clerk@5.0.0-beta.45 --save-exact
npm i @clerk/localizations@2.5.1-snapshot.v22b1fc0 --save-exact
npm i @clerk/nextjs@5.2.6-snapshot.v22b1fc0 --save-exact
npm i @clerk/remix@4.2.5-snapshot.v22b1fc0 --save-exact
npm i @clerk/clerk-sdk-node@5.0.18-snapshot.v22b1fc0 --save-exact
npm i @clerk/tanstack-start@0.1.9-snapshot.v22b1fc0 --save-exact
npm i @clerk/testing@1.2.1-snapshot.v22b1fc0 --save-exact |
| const url = new URL(`https://${frontendApiNoProtocol}/v1/client/handshake`); | ||
| url.searchParams.append('redirect_url', redirectUrl?.href || ''); | ||
| url.searchParams.append('suffixed_cookies', authenticateContext.suffixedCookies.toString()); | ||
| url.searchParams.append('suffixed_cookies', 'true'); |
There was a problem hiding this comment.
I'm going to revert this because I think its not needed at the moment
For production instances that use the latest ClerkJS and backend SDKs if the FAPI suffixed cookies are disabled, in every page refresh a handshake is triggered. To fix this we should use the un-suffixed cookies when the suffixed session exists but the suffixed client_uat does not exist.
| // This case can be reproduced for production instances when new ClerkJS and backend SDK | ||
| // are used but the FF in FAPI is disabled |
There was a problem hiding this comment.
| // This case can be reproduced for production instances when new ClerkJS and backend SDK | |
| // are used but the FF in FAPI is disabled |
| // In case of incorrectly setup suffixed cookies (session exists but client_uat missing) | ||
| // let's use the un-suffixed cookies to keep the existing behavior. | ||
| // This case can be reproduced for production instances when new ClerkJS and backend SDK | ||
| // are used but the FF in FAPI is disabled |
There was a problem hiding this comment.
| // In case of incorrectly setup suffixed cookies (session exists but client_uat missing) | |
| // let's use the un-suffixed cookies to keep the existing behavior. | |
| // This case can be reproduced for production instances when new ClerkJS and backend SDK | |
| // are used but the FF in FAPI is disabled | |
| // If a suffixed session cookie exists but the corresponding client_uat cookie is missing, fallback to using | |
| // unsuffixed cookies. | |
| // This handle the scenario where an app has been deployed using an SDK version that supports suffixed | |
| // cookies, but FAPI for its Clerk instance has the feature disabled (eg: if we need to temporarily disable the feature). |
22b1fc0 to
aef391c
Compare
…enabled' into fix/backend-sdk-without-fapi-ff-enabled
Co-authored-by: Stefanos Anagnostou <anagstef@users.noreply.github.com>
Co-authored-by: Nikos Douvlis <nikosdouvlis@gmail.com> Co-authored-by: Stefanos Anagnostou <anagstef@users.noreply.github.com>
Description
For production instances that use the latest ClerkJS and backend SDKs if the suffixed cookies are disabled in FAPI, in every page refresh a handshake is triggered.
To fix this we should use the un-suffixed cookies when the suffixed client_uat does not exist but the suffixed session exists.
Checklist
npm testruns as expected.npm run buildruns as expected.Type of change