user14199346
user14199346

Reputation:

Nuxt Env variables not working on Netlify

I am trying to deploy to Netlify through github my static generated app made with Nuxt JS, and the issue I am having is with the API_KEY variable inside my .env file, even though I added them to the environement variables available on my Netlify Project Settings, I am still getting a 404 error and undefined api key on my app console log.

Upvotes: 1

Views: 1740

Answers (1)

TheAlexLichter
TheAlexLichter

Reputation: 7289

If you intend use the env variables in your app (outside of the nuxt.config.js), then you might want to switch to runtimeConfig.

//nuxt.config.js
export default {
  publicRuntimeConfig: {
    baseURL: process.env.BASE_URL
  }
}

//in your app
this.$config.baseURL

Upvotes: 0

Related Questions