Skip to content

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

Merged
merged 3 commits into from
May 25, 2022

Conversation

ericapisani
Copy link

Summary

As outlined in the issue linked below, a user could have defined NEXTAUTH_URL in the next.config.js file and ,prior to these changes, the plugin would override the value to set it to what process.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 the next-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

  1. Visit the Deploy Preview (insert link to specific page) ...

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

Fixes #1345

Standard checks:

  • Check the Deploy Preview's Demo site for your PR's functionality
  • Add docs when necessary

🧪 Once merged, make sure to update the version if needed and that it was published correctly.

A user could have defined this in next.config.js and the existing logic
within the plugin overrides it.
@ericapisani ericapisani requested a review from a team May 25, 2022 18:29
@ericapisani ericapisani self-assigned this May 25, 2022
@netlify
Copy link

netlify bot commented May 25, 2022

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
🔨 Latest commit f9f8a47
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/628e7a0b252cdb0008162f82
😎 Deploy Preview https://deploy-preview-1360--netlify-plugin-nextjs-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 25, 2022

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
🔨 Latest commit f9f8a47
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/628e7a0b7f2ff30008aa5f50
😎 Deploy Preview https://deploy-preview-1360--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@ericapisani ericapisani added the type: bug code to address defects in shipped code label May 25, 2022
@netlify
Copy link

netlify bot commented May 25, 2022

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
🔨 Latest commit f9f8a47
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/628e7a0b8f799a000850c64e
😎 Deploy Preview https://deploy-preview-1360--netlify-plugin-nextjs-export-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 25, 2022

Deploy Preview for next-plugin-edge-middleware canceled.

Name Link
🔨 Latest commit f9f8a47
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/628e7a0ba8df3a00087caca5

@netlify
Copy link

netlify bot commented May 25, 2022

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
🔨 Latest commit f9f8a47
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/628e7a0b53bd0b00093ea2b7
😎 Deploy Preview https://deploy-preview-1360--netlify-plugin-nextjs-static-root-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 25, 2022

Deploy Preview for next-i18next-demo ready!

Name Link
🔨 Latest commit f9f8a47
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/628e7a0b06c49800098d2d2e
😎 Deploy Preview https://deploy-preview-1360--next-i18next-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 25, 2022

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
🔨 Latest commit f9f8a47
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/628e7a0b69854a00086e532c
😎 Deploy Preview https://deploy-preview-1360--netlify-plugin-nextjs-next-auth-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 25, 2022

Deploy Preview for next-plugin-rsc-demo ready!

Name Link
🔨 Latest commit f9f8a47
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-rsc-demo/deploys/628e7a0bb1bc2d0009cb38ca
😎 Deploy Preview https://deploy-preview-1360--next-plugin-rsc-demo.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@cypress
Copy link

cypress bot commented May 25, 2022



Test summary

22 0 0 0


Run details

Project netlify-plugin-nextjs-default-demo
Status Passed
Commit 54cecd6 ℹ️
Started May 25, 2022 6:51 PM
Ended May 25, 2022 6:53 PM
Duration 01:35 💡
OS Linux Ubuntu - 20.04
Browser Chrome 101

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

@cypress
Copy link

cypress bot commented May 25, 2022



Test summary

2 0 0 0


Run details

Project netlify-plugin-nextjs-nx-monorepo-demo
Status Passed
Commit 54cecd6 ℹ️
Started May 25, 2022 6:52 PM
Ended May 25, 2022 6:53 PM
Duration 01:09 💡
OS Linux Ubuntu - 20.04
Browser Chrome 101

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

@cypress
Copy link

cypress bot commented May 25, 2022



Test summary

7 0 0 0


Run details

Project netlify-plugin-nextjs-static-demo
Status Passed
Commit 54cecd6 ℹ️
Started May 25, 2022 6:52 PM
Ended May 25, 2022 6:54 PM
Duration 01:27 💡
OS Linux Ubuntu - 20.04
Browser Chrome 101

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)

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

Copy link
Author

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

sarahetter
sarahetter previously approved these changes May 25, 2022
Copy link

@sarahetter sarahetter left a 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!

@kodiakhq kodiakhq bot merged commit 9010da3 into main May 25, 2022
@kodiakhq kodiakhq bot deleted the ep/1345-fix-nextauth-override branch May 25, 2022 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: NEXTAUTH_URL is overridden
2 participants