-
Notifications
You must be signed in to change notification settings - Fork 397
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
fix: load from process.env.VERCEL_URL
if AUTH0_BASE_URL
not set
#585
Conversation
@ctjlewis is attempting to deploy a commit to the Auth0 Team on Vercel. A member of the Team first needs to authorize it. |
@adamjmcgrath I would really recommend reopening and merging this PR. Whatever logic exists for not doing this automatically despite the library being designed for deployment to Vercel, it's not worth it in practice. I have to look this PR up every time I add the library to a new project because it's the only way to keep the base URL consistent across live deploys. It's just an Not taking this approach results in unexpected behavior when users add the library to a project and attempt to deploy to Vercel, the deploy pipeline Next was designed for. |
You know, it's still impossible to deploy a working dev environment to production without being incredibly crafty and realizing you have to manually shim the AUTH0_BASE_URL to match VERCEL_URL at runtime. This is objectively suboptimal software design. Just terrible work. For visitors from GoogleWorkaround is: process.env.AUTH0_BASE_URL = process.env.AUTH0_BASE_URL || process.env.NEXT_PUBLIC_DOMAIN || process.env.VERCEL_URL; And setting the |
@adamjmcgrath I think about this every time I need to hack this together manually in a new project because it will otherwise not recognize the correct base URL when deployed to a domain, which is obviously necessary for any site running in production. |
Hi @ctjlewis - thanks for your feedback, and apologies we didn't accept your PR Our instructions for assigning the We also have instructions for handling production deployments in Vercel here https://github.com/auth0/nextjs-auth0/tree/main/examples#production-deployments-or-other-environments-with-fixed-urls - where we recommend using the Vercel dashboard If you think these instructions are incorrect, feel free to raise an issue with steps to reproduce and we'd be happy to investigate it for you. |
Yes, it's an absolute nightmare to try to figure this out each time. We need to restate the linked docs in a step-by-step format, with screenshots, and move it into the main README. This is a Next-specific library and brain surgery is required to ship it to Vercel so this needs to be front and center. A note will also be added that the production base URL override means the deploy URL (like |
I try place |
It doesn't work for me either. It seems that the preview deployment doesn't read |
Yeah, this team refuses to listen to me regarding the pattern. It should just read from VERCEL_URL automatically. For now, you must go into Project Settings > Environment Variables, and override |
@ctjlewis But how do you make it work for preview deployments? Here's my current GitHub actions workflow setup:
I'm setting |
@thexpand If I needed preview URLs to work I used to use this shim:
But it's not convenient. The library generally poorly supports this despite being designed specifically for deploying on this exact architecture. Maintainers linked some docs when they closed this PR, would review those but IIRC the instructions aren't reliable. |
@ctjlewis Oh, thanks! I though that'll do it, but it's not ideal. I hope it works as a workaround for Next.js 13.4+ with the /app directory. I'll try it out and post back the results. |
Hmm, actually I got it working with a
And then the steps for my GitHub action for preview deployments are configured like this:
|
Potentially fixes #383.
Description
See #383 (comment).
References
Testing
Checklist
main