-
Notifications
You must be signed in to change notification settings - Fork 86
fix: don't override user defined NEXTAUTH_URL #1360
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
A user could have defined this in next.config.js and the existing logic within the plugin overrides it.
✅ Deploy Preview for netlify-plugin-nextjs-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-export-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-edge-middleware canceled.
|
✅ Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-i18next-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-rsc-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
const nextAuthUrl = `${process.env.URL}${basePath}` | ||
config.config.env.NEXTAUTH_URL = nextAuthUrl | ||
|
||
await updateRequiredServerFiles(publish, config) |
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.
I'm not sure what's already in these files - if the user sets their own NEXTAUTH_URL does it already exist in the required-server-files.json
? Just wondering why we're only doing this in the else
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.
... if the user sets their own NEXTAUTH_URL does it already exist in the required-server-files.json
That's correct. required-server-files.json
contains configuration related to the site after running the build command (next build
in this case) so any environment variables defined by the user in next.config.js
will appear within this file under the config.env
object.
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!
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.
Just a couple of questions, nothing blocking. LGTM!
Summary
As outlined in the issue linked below, a user could have defined
NEXTAUTH_URL
in thenext.config.js
file and ,prior to these changes, the plugin would override the value to set it to whatprocess.env.URL
is.These changes check to see if a
NEXTAUTH_URL
already exists within the generated server files after building the site and will continue on if it exists, or generate a default value if one doesn't.Logging was added for the scenario where a user defined
NEXTAUTH_URL
exists in order to make it clear about what the plugin is seeing with respect to thenext-auth
related configuration.These changes also add the
chance
package for unit tests so we can avoid hard coding test values where possible.Test plan
Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal
Fixes #1345
Standard checks:
🧪 Once merged, make sure to update the version if needed and that it was published correctly.