Repository navigation
fix(clerk-js,astro,nuxt,tanstack-react-start,remix,react-router): Introduce helper function to prevent infinite handshake in Netlify - #5656
Conversation
🦋 Changeset detectedLatest commit: 4eb903a The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 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 Git ↗︎
|
|
!snapshot |
|
Hey @wobsoriano - 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/agent-toolkit@0.0.24-snapshot.v20250417032557 --save-exact
npm i @clerk/astro@2.6.6-snapshot.v20250417032557 --save-exact
npm i @clerk/backend@1.29.1-snapshot.v20250417032557 --save-exact
npm i @clerk/chrome-extension@2.2.31-snapshot.v20250417032557 --save-exact
npm i @clerk/clerk-js@5.61.2-snapshot.v20250417032557 --save-exact
npm i @clerk/elements@0.23.16-snapshot.v20250417032557 --save-exact
npm i @clerk/clerk-expo@2.9.14-snapshot.v20250417032557 --save-exact
npm i @clerk/expo-passkeys@0.2.8-snapshot.v20250417032557 --save-exact
npm i @clerk/express@1.4.7-snapshot.v20250417032557 --save-exact
npm i @clerk/fastify@2.2.7-snapshot.v20250417032557 --save-exact
npm i @clerk/localizations@3.13.12-snapshot.v20250417032557 --save-exact
npm i @clerk/nextjs@6.16.0-snapshot.v20250417032557 --save-exact
npm i @clerk/nuxt@1.5.7-snapshot.v20250417032557 --save-exact
npm i @clerk/clerk-react@5.28.2-snapshot.v20250417032557 --save-exact
npm i @clerk/react-router@1.2.7-snapshot.v20250417032557 --save-exact
npm i @clerk/remix@4.5.19-snapshot.v20250417032557 --save-exact
npm i @clerk/shared@3.7.2-snapshot.v20250417032557 --save-exact
npm i @clerk/tanstack-react-start@0.13.7-snapshot.v20250417032557 --save-exact
npm i @clerk/testing@1.4.41-snapshot.v20250417032557 --save-exact
npm i @clerk/themes@2.2.34-snapshot.v20250417032557 --save-exact
npm i @clerk/types@4.54.2-snapshot.v20250417032557 --save-exact
npm i @clerk/vue@1.6.3-snapshot.v20250417032557 --save-exact |
| publishableKey: string; | ||
| }) { | ||
| // eslint-disable-next-line turbo/no-undeclared-env-vars | ||
| const isOnNetlify = process.env.URL?.endsWith('netlify.app') || Boolean(process.env.NETLIFY_FUNCTIONS_TOKEN); |
There was a problem hiding this comment.
URL and NETLIFY_FUNCTIONS_TOKEN are runtime environment variables injected by Netlify. We can use this to determine if this patch should run.
There was a problem hiding this comment.
Can't we use process.env.NETLIFY?
URL will not always end with netlify.app since it can also be your custom domain, as per https://docs.netlify.com/functions/environment-variables/#functions
There was a problem hiding this comment.
It's for build time only and not available in other SDKs at runtime (but worked in Astro 🤔 ). I added it just now as fallback!
tmilewski
left a comment
There was a problem hiding this comment.
:nit: It feels to me like packages/shared/src/__tests__/netlifyCacheHandler.ts would want to be packages/shared/src/__tests__/netlifyCacheHandler.test.ts
Description
This PR is a follow-up to #4745 but applies the changes to all SDKs (except
@clerk/nextjs).This fixes a handshake redirect loop issue in apps deployed to Netlify with Clerk development instance (see #5547). I opened a thread on Netlify's side about this with full info, which can be seen here. Multiple solutions have been tried, including the
Netlify-Varyheader with no success.I also thought of moving the
handleNetlifyCacheInDevInstancefunction to@clerk/backendbut this may introduce unnecessary complexity. The goal of this PR is to temporarily fix the issue until we find a better solution but open for discussions!You can test it with the ff. apps deployed to Netlify using this PRs snapshots + Clerk dev instance (you should not experience a redirect loop when visiting any of them):
Resolves ECO-603
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change