How to redirect to generated staging links (with Vercel)?

I’m building a Nextjs app deployed with Vercel. Vercel is unique in that it generates preview links for every commit you make so you can see your changes live before they get rolled into production.

The challenge I’m facing is that logins do not work on these preview links because I’m unable to allow list them in my application settings. These unique links have the following URL structure:

"https://${project}-${randomGeneratedString}-${org}.vercel.app/"

// so for example
"https://myproject-n30zkjlc5-myorg.vercel.app/"

In my auth0 application settings I tried setting Allowed Callback URLs/CORS/origins to the following, but it doesnt seem to work.

https://mproject-*-myorg.vercel.app

Is there any way to get wild card callbacks like this to work? Otherwise it makes testing on staging Vercel links difficult since we can’t login successfully.

1 Like

After some googling I found the solution. I was on the right track with the wild card, but I also needed to set my Vercel AUTH0_ISSUER_BASE_URL to

https://${VERCEL_GIT_REPO_SLUG}-${VERCEL_GIT_COMMIT_REF}-${VERCEL_GIT_REPO_OWNER}.vercel.app
2 Likes

Glad you have figured it out and thanks for sharing with the rest of community!

1 Like

Hey team!

This topic seems related to the new Auth0 Integration available new in Vercel Marketplace. This is the first version of this integration, and we welcome your feedback to improve future iterations.

You’ll need an existing Vercel project to use the new integration to build and customize the Identity flow. You can either import your project into Vercel or use a Vercel template so you don’t have to start from scratch like our SaaStart template to deploy a production-ready B2B SaaS app in minutes (learn more here).

If you find yourself having questions regarding this new integration for the next two weeks, we are hosting an Ask Me Anything session. Our Product Expert will provide comprehensive written answers on August 8th from 8 AM to 10 AM PST.

Find out more about Auth0 Integration and learn more about AMA.

Thanks!