Issue getting .env to work on Netlify. Nuxt Netlify .env

Viewed 596

Issue getting .env to work on Netlify.

My repo is here: nuxt-axios-sheets

I'm getting key=undefined in the browser console: Failed to load resource: the server responded with a status of 400 ()

  • This is a Nuxt project (1.4.2).
  • I'm using dotenv 1.1.1.
  • It works on my local machine.
  • I set up the key/value on the Netlify dashboard.
  • I set up the google sheets api for the Netlify URL.
2 Answers

Since your .env file is not on your Github repo and it should not be there, you have to read the environment variables of Netlify using process.env or with a library like https://www.npmjs.com/package/getenv .

For that, you just need to define Environment Variables under the 'Site settings > Build & deploy > Environment > Environment variables'.

Related