0

Current Setup

I load my Mapbox access token into my next.js app as process.env.NEXT_PUBLIC_MAPBOX_TOKEN. The token is stored in my .env.local file as NEXT_PUBLIC_MAPBOX_TOKEN and also in the s3 QA server config.

Problem

The Mapbox token is read when I'm in local development and loads the map, but when I visit the live QA link, it isn't read and the map doesn't load.

What are the possible causes for this problem?

Zack Carlson
  • 89
  • 1
  • 6

1 Answers1

0

.env.local contains environment variables that are specific to your local machine.

You can define them .env or .env.production...

Check this for more information.

https://nextjs.org/docs/basic-features/environment-variables

Chuck
  • 776
  • 5
  • 18
  • I've already checked the link you sent me before and based on that I prefixed my token with `NEXT_PUBLIC_`. I don't want to expose any mapbox tokens inside of `.env.*` (except for `.env.local` when developing local). – Zack Carlson Jul 15 '21 at 18:36
  • The solution was to add the mapbox token as a build time variable in `s3`. – Zack Carlson Jul 15 '21 at 21:35
  • @ZackCarlson Feel free to add the solution you found as an answer to your own question. – juliomalves Jul 16 '21 at 17:52