Set environment variable for build in Netlify

后端 未结 6 1105
隐瞒了意图╮
隐瞒了意图╮ 2020-12-03 05:52

I\'m trying to set an environment variable for an API key that I don\'t want in my code. My source javascript looks something like this :

.get(`http://api-ur         


        
6条回答
  •  旧巷少年郎
    2020-12-03 06:21

    If you're using Nuxt JS there is a more "straight forward" approach.

    Just edit the nuxt.config.js like so:

    module.exports = {
      env: {
        GOOGLE_API_KEY: process.env.GOOGLE_API_KEY
    
      },
      // ...
    

    Then add the GOOGLE_API_KEY to Netlify through the build environment variables as usual.

    Credit goes to yann-linn and his answer on github.

提交回复
热议问题