I'm using VueJS 3 and when I try to use process.env.CONSTANT to get a value from the environment variables, I have an error message saying that process does not exist.
I don't understand why I have this error because with VueJS version 3 I don't need to use the dotenv plugin.
WARNING
Do not store any secrets (such as private API keys) in your app!
Environment variables are embedded into the build, meaning anyone can view them by inspecting your app's files.
Does it mean that no secret key should be written in the .env file ? I thought it was like in Laravel. So I have a new question : where is it possible de save securely the secret keys in VueJS ?
@vincent15000 The .env file is fine as long as you encrypt the values. Vue runs in the frontend so there is no server in between that can securely get those values. Instead, you need to use a backend to access things behind a security token. You can use environment keys for different things, except for private tokens like the warning mentions.
Since Vue 3 you need to prefix them with VUE_APP_.
@MaverickChan Just Laravel with VueJS. That's why I thought it was automatic.
@bobbybouwmann According to the documentation, VUE_APP_ prefix is not obligatory. But I have difficulty to understand the difference with the other types of variables. Would the other types not embedded in the build ?