Wrong redirect URL on production
bvaughn opened this issue · 1 comments
Checklist
- The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
I followed the auth0 instructions which recommend configuring the .env.production
file like so:
NEXT_PUBLIC_AUTH0_BASE_URL=$VERCEL_URL
The Vercel documentation says the following about the VERCEL_URL
variable (emphasis mine):
The domain name of the generated deployment URL. Example: *.vercel.app.
Combining the above means that auth works fine on preview deployments (generated URLs) but when I try to use my vanity URL, sign-in fails because of a bad/mismatching redirect_uri
.
For example, let's say that my production URL is example.vercel.app. When I try to sign in, the AUTH0_BASE_URL
is causing the redirect_uri
to get set to a generated deployment URL like example-auj9zcz7f-myorg.vercel.app, which then fails.
Any suggestions?
Reproduction
- Follow the guide in https://vercel.com/docs/projects/environment-variables/system-environment-variables
Additional context
No response
nextjs-auth0 version
3.5.0
Next.js version
14.1.0
Node.js version
N/A
I read a lot of docs and GitHub issues and eventually found my way to the note at the bottom of this page:
https://github.com/auth0/nextjs-auth0/blob/main/example-app/README.md#production-deployments-or-other-environments-with-fixed-urls
So I set a production only environment variable in NextJS for AUTH0_BASE_URL
that has the value of my vanity URL and redeployed and that fixed the login issue.