Skip to content
Discussion options

You must be logged in to vote

To anyone coming here to know how to have an env variable of NEXT_PUBLIC_URL containing:

Here's how to do it "the right way" as of September 2021.

For development:

# .env.development
NEXT_PUBLIC_URL=http://localhost:3000

For preview URLs:

# .env.production
NEXT_PUBLIC_URL=https://$NEXT_PUBLIC_VERCEL_URL

⚠️ Make sure to auto expose system env variables in Vercel env variable admin:

For production (yourdomain.com), create a new env variable on the Vercel dashboard, only for the production env:

I wish this were easier, and we could define the main domain for a proj…

Replies: 19 comments 38 replies

Comment options

You must be logged in to vote
3 replies
@zhenghaohe
Comment options

@samlak
Comment options

@Sammeeey
Comment options

Comment options

You must be logged in to vote
6 replies
@brunos3d
Comment options

@atawfique21
Comment options

@joelbiffin
Comment options

@WebDev-Akhil
Comment options

@Sammeeey
Comment options

Comment options

vvo
Sep 9, 2021
Collaborator

You must be logged in to vote
10 replies
@diveddie
Comment options

@jacob-leger
Comment options

@Code-Victor
Comment options

@leog
Comment options

@OyintarePaul
Comment options

Answer selected by vvo
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jinsley8
Comment options

@WebDev-Akhil
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@curiosbasant
Comment options

@crisu83
Comment options

@OyintarePaul
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@jacob-leger
Comment options

@juliankoehn
Comment options

@jacob-leger
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@leerob
Comment options

@subproject22
Comment options

@amyegan
Comment options

amyegan Jul 17, 2024
Collaborator

@jonahallibone
Comment options

@jonahallibone
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@pawlean
Comment options

pawlean Aug 30, 2024
Collaborator

@petedegraw
Comment options

Comment options

You must be logged in to vote
1 reply
@jacob-leger
Comment options

Comment options

You must be logged in to vote
3 replies
@leonardofaria
Comment options

@KoenRijpstra
Comment options

@ignaciodiazb
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet