Can't access gatsby environment variables on the client side

前端 未结 5 1177
旧时难觅i
旧时难觅i 2021-02-19 00:44

I set up .env file and gatsby-config.js as below.

// .env.development
GATSBY_API_URL=https://example.com/api
         


        
5条回答
  •  长发绾君心
    2021-02-19 01:37

    Make sure you've included

    require("dotenv").config({ path: .env.${process.env.NODE_ENV}, })

    in your gatsby-config.js file before you start using your ENV variables.

提交回复
热议问题