question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hosting via Vercel not working because of AUTH0_BASE_URL.

See original GitHub issue

Description

Hi, I would like to reopen https://github.com/auth0/nextjs-auth0/issues/383, as https://github.com/auth0/nextjs-auth0/pull/404 did not fix the problem, as you can see in the last comments of https://github.com/auth0/nextjs-auth0/issues/383.

The documentation at https://github.com/auth0/nextjs-auth0/blob/main/examples/README.md#assigning-the-auth0_base_url seems wrong to me, as the env key in config and the webpack DefinePlugin don’t work for files in node_module, which are not touched by webpack.

Moreover, on a Vercel side, the VERCEL_URL reference the “by commit domain”, and not the “by PR domain”, so we can’t use auth0 with the standard PR domain.

We have to figure out another way to do this.

Any thoughts about this?

Thanks.

Environment

  • Version of this library used: v1.4.0
  • Version of the platform or framework used, if applicable: Next 10.2.3 with Vercel

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:31 (10 by maintainers)

github_iconTop GitHub Comments

7reactions
tusbarcommented, Jul 9, 2021

I can confirm that committing a .env.production with the following works.

# .env.production
AUTH0_BASE_URL=${VERCEL_URL}

Also, specifying AUTH0_BASE_URL for your production domain in the Vercel environment config (through GUI or CLI) will properly override what’s defined in the .env.production file.

4reactions
adamjmcgrathcommented, Jul 9, 2021

Managed to have a work-around for this issue by overriding Vercel’s Build Command AUTH0_BASE_URL=“$VERCEL_URL” yarn build

@sioquim - I’ve been testing this and assiging AUTH0_BASE_URL for the build command (AUTH0_BASE_URL="$VERCEL_URL" npm build) doesn’t work because it only provides the AUTH0_BASE_URL during the Build Step not during Serverless Function execution when it’s required by the SDK. Am I missing something?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auth0 works on localhost but not on vercel
everything works on localhost smoothly, then deployed to vercel. the credential login works well, but the Auth0 give error like this. Please ...
Read more >
[SOLVED] NextJS Vercel deployment issue. 500 server ...
When working locally everything works as expected but when attempting to login on the vercel site auth0 returns a 500.
Read more >
Next.js Vercel access_denied (unauthorized)
Answer: access_denied happens when Auth0 can't issue a token (Auth0 refuses the authorization). It can happen for many reasons, and the ...
Read more >
How to redirect to generated staging links (with Vercel)?
In my auth0 application settings I tried setting Allowed Callback URLs/CORS/origins to the following, but it doesnt seem to work.
Read more >
The Ultimate Guide to Next.js Authentication with Auth0
Static hosting sites (like Vercel, Amazon S3, Azure Blob Storage, ... The base url of your application AUTH0_BASE_URL=http://localhost:3000 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found