I’ve read the docs:
https://codesandbox.io/docs/learn/environment/secrets
And I have stored my environment variables accordingly:
However, when I actually try to access these environment variables in the code with:
const GOOGLE_MAPS_API_KEY = process.env.GOOGLE_MAPS_API_KEY;
…it doesn’t work. And yes I have already confirmed that my API request works properly if I hard-code the API KEYs.
Is process.env.[VAR_NAME]
not the correct way to do this?
AFAIK, this is the standard way that environment variables are accessed in a React project. Unfortunately, there is nothing in the CodeSandbox docs that specifies how to access the environment variables. They only tell you where to store them.