-
Notifications
You must be signed in to change notification settings - Fork 337
fix(clerk-js,astro,nuxt,tanstack-react-start,remix,react-router): Introduce helper function to prevent infinite handshake in Netlify #5656
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 0cfc484 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/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --save-exact
npm i @clerk/[email protected] --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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Co-authored-by: Lennart <[email protected]>
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-Vary
header with no success.I also thought of moving the
handleNetlifyCacheInDevInstance
function to@clerk/backend
but 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 test
runs as expected.pnpm build
runs as expected.Type of change