Gatsby js undefined environment variables

Good morning, I’m using gatsby.js and the environment variables I define in the netlify settings appear as undefined and don’t take them well.

Has the same thing happened to anyone else?

Hey @xAgustin93 and welcome to Community! :wave:

Starters for 10; have you seen this guide?

If I’ve tried what you say about adding the dotenv, but it still doesn’t work that way, that’s how I’ve got it condigurated.

require(“dotenv”).config({ path: “.env” });

const API_KEY_WEB = process.env.API_KEY_WEB;

hi there,

for Gatsby, you need to use the prefix GATSBY_ for things to work properly. More in this thread: