Skip to content

fix: use process.env.URL when deploying to production #1680

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 9 commits into from
Oct 25, 2022
Merged

Conversation

ericapisani
Copy link

@ericapisani ericapisani commented Oct 12, 2022

Summary

  • Upgrades the version to next-auth to the latest
  • Updates the logic for creating the default NEXTAUTH_URL.
    • In a production context, the unique hash that gets pre-pended to the URL leads to issues because next-auth uses that URL as the basis for updating it's provider information. For instance - the callback URL used for OAuth applications (since it expects a stable value). This change makes the URL stable by using the 'URL' rather than the DEPLOY_PRIME_URL when it detects that the CONTEXT is set to 'production'

Test plan

  1. Visit the Deploy Preview - https://deploy-preview-1680--netlify-plugin-nextjs-next-auth-demo.netlify.app/
  2. Visit the '/admin' and '/me' pages.
  • Visiting those pages should not result in a server error
  • If you inspect the 'sign in' button shown as part of the default demo when visiting /admin or /me, the URL that it goes to should be the URL of the site (e.g: https://deploy-preview-1680--netlify-plugin-nextjs-next-auth-demo.netlify.app/api/callback....)
  1. Visiting this test site https://upgrade-next-auth--ep-next-auth.netlify.app/
  2. Visit the /admin and /me pages
  • Visiting those pages should not result in a server error
  • If you inspect the 'sign in button' on /admin or /me, the URL that it goes to should start with https://ep-next-auth.netlify.app/ not https://upgrade-next-auth--ep-next-auth.netlify.app
  • If you sign in (there's a test OAuth app backing that site), you should be able to visit the /me endpoint, but the /admin page should still be inaccessible since userRole: admin is not set on the returned token that makes that page accessible.

@ericapisani ericapisani added the type: chore work needed to keep the product and development running smoothly label Oct 12, 2022
@ericapisani ericapisani self-assigned this Oct 12, 2022
@netlify
Copy link

netlify bot commented Oct 12, 2022

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

Name Link
🔨 Latest commit a1b429a
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/6358150ed901920009765f94
😎 Deploy Preview https://deploy-preview-1680--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 Oct 12, 2022

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

Name Link
🔨 Latest commit a0ca064
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/6346dd0e7467250008d78cbb
😎 Deploy Preview https://deploy-preview-1680--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 Oct 12, 2022

Deploy Preview for next-i18next-demo failed.

Name Link
🔨 Latest commit a1b429a
🔍 Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/6358150e212d860008ee4d43

@netlify
Copy link

netlify bot commented Oct 12, 2022

Deploy Preview for next-plugin-canary ready!

Name Link
🔨 Latest commit a1b429a
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/6358150ee8b83900091ded11
😎 Deploy Preview https://deploy-preview-1680--next-plugin-canary.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 Oct 12, 2022

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

Name Link
🔨 Latest commit a1b429a
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/6358150eeb6a7300081bea4b
😎 Deploy Preview https://deploy-preview-1680--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 Oct 12, 2022

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

Name Link
🔨 Latest commit a1b429a
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/6358150e2f340900083e8236
😎 Deploy Preview https://deploy-preview-1680--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 Oct 12, 2022

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

Name Link
🔨 Latest commit a0ca064
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-rsc-demo/deploys/6346dd0e12563e0009c05ea5
😎 Deploy Preview https://deploy-preview-1680--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.

@netlify
Copy link

netlify bot commented Oct 12, 2022

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
🔨 Latest commit a1b429a
🔍 Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/6358150e70376b000824cc8e
😎 Deploy Preview https://deploy-preview-1680--nextjs-plugin-custom-routes-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 Oct 12, 2022

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

Name Link
🔨 Latest commit a1b429a
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/6358150ec0bd42000bc8c68e
😎 Deploy Preview https://deploy-preview-1680--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.

@netlify
Copy link

netlify bot commented Oct 12, 2022

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
🔨 Latest commit a1b429a
🔍 Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/6358150eb0eecd00087d09f6
😎 Deploy Preview https://deploy-preview-1680--next-plugin-edge-middleware.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 Oct 24, 2022

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

Name Link
🔨 Latest commit a1b429a
🔍 Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/6358150e42e55a000a68d028
😎 Deploy Preview https://deploy-preview-1680--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 Oct 24, 2022

Deploy Preview for ep-next-auth ready!

Name Link
🔨 Latest commit a1b429a
🔍 Latest deploy log https://app.netlify.com/sites/ep-next-auth/deploys/6358150e387eb2000865a23e
😎 Deploy Preview https://deploy-preview-1680--ep-next-auth.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 changed the title chore: upgrade next-auth to latest fix: use process.env.URL when deploying to production Oct 24, 2022
@github-actions github-actions bot added the type: bug code to address defects in shipped code label Oct 24, 2022
@ericapisani ericapisani removed the type: chore work needed to keep the product and development running smoothly label Oct 24, 2022
@ericapisani ericapisani marked this pull request as ready for review October 24, 2022 21:27
@ericapisani ericapisani requested a review from a team October 24, 2022 21:27
nickytonline
nickytonline previously approved these changes Oct 25, 2022
Copy link

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

Looks great @ericapisani! Left some dusty comments 🚀

nickytonline
nickytonline previously approved these changes Oct 25, 2022
Copy link

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

Thanks for making the changes! 🚀

Copy link

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

🚀

@kodiakhq kodiakhq bot merged commit 4b08911 into main Oct 25, 2022
@kodiakhq kodiakhq bot deleted the upgrade-next-auth branch October 25, 2022 17:00
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.

2 participants