-
Notifications
You must be signed in to change notification settings - Fork 295
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
fix(astro): Prevent Netlify from doing a handshake redirect loop #4745
fix(astro): Prevent Netlify from doing a handshake redirect loop #4745
Conversation
🦋 Changeset detectedLatest commit: 4e352f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 ↗︎
|
function handleNetlifyCacheInDevInstance(locationHeader: string, requestState: RequestState) { | ||
// Only run on Netlify environment and Clerk development instance | ||
// eslint-disable-next-line turbo/no-undeclared-env-vars | ||
if (import.meta.env.NETLIFY && isDevelopmentFromPublishableKey(requestState.publishableKey)) { |
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.
Description
Netlify caches the responses from pages. When the middleware initiates a handshake redirect and returns to the original URL, Netlify serves the cached response (along with the cookies), leading to an infinite handshake redirect loop.
I've tried using Netlify's cache key variations but it doesn't seem to work.
This PR adds a cache bust parameter to the original URL to prevent Netlify from serving the cached response. The parameter is automatically removed from the URL after the page loads.
I don't have e2e tests for it, but you can compare the ff.:
Resolves ECO-202
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change