Access .env file from Content Script

Viewed 681

Is it possible to access variables from .env file from Content Script? I am building a Chrome Extension and I have javascript Content Script file from which I listen to events on the browser page. I would like to make an API call, so I need to access my API key, which is stored in .env file. When i try to call variables as const key = proccess.env.API_KEY i get an error: Uncaught ReferenceError: process is not defined.

I tried require('dotenv').config(); to help me with that problem, but since this is a normal js file and not Node.js, i get an erorr: Uncaught ReferenceError: require is not defined

So is there a way to load .env variables in normal JavaScript? Or should I use different approach?

0 Answers
Related