-
Notifications
You must be signed in to change notification settings - Fork 47
fix(preview): Ensure the protocol is correct in redirects from server actions during preview mode #689
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
Conversation
🦋 Changeset detectedLatest commit: ad79fcb The changes in this PR will be included in the next version bump. 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 |
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.
Thanks for the fix!
Could we drop the condition url.hostname === "localhost"
and always set process.env.__NEXT_PRIVATE_ORIGIN
?
commit: |
In theory that shouldn't be a problem. |
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.
LGTM, thanks!
Thanks for both the fix and the detailed PR description.
I have updated the code to unconditionally apply the fix.
Closes #686.
Important to note this didn't only affect
next-auth
. All redirects from server actions was affected in preview mode.wrangler dev
would hang and give an error as it would try to send a request tohttps
.Through my research I figured out that Next internally uses
process.env.__NEXT_PRIVATE_ORIGIN
in standalone mode. They set it duringstartServer
on this line. To align with this behavior in preview mode this should be set to the origin during the initialization.Affected lines in Next:
proto
would always behttps
here, thus thefetch
below would recieve the wrong protocol in itsfetchUrl
.