How to use environment variables on the server? #17188
-
I'm having a hard time figuring out, how to get environment variables working on the server
When calling console.log(process.env.API); in a function in my code, would correctly write the address set in the above code. Unfortunately this only seems to work in my local dev environment I then called quasar build and copied the files to the server. Unfortunately calling process.env.API result in this error: ReferenceError: process is not defined if process is not defined in the built files, how can I access the environment variables? And how do I differentiate between test and production on a server, when writing the environment variables? As far as I can tell, Quasar can only see the difference between production and development. What is the most correct way to do it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I found the problem. I also called process.env.NODE_ENV (an environment variable I had removed). I would expect calling this would just give me 'undefined'. Having an error saying 'process is not defined' threw me on a wild-goose-chase, as I expected this to mean that it couldn't find... well... process... not that it couldn't find the environment variable I was searching for |
Beta Was this translation helpful? Give feedback.
I found the problem. I also called process.env.NODE_ENV (an environment variable I had removed). I would expect calling this would just give me 'undefined'. Having an error saying 'process is not defined' threw me on a wild-goose-chase, as I expected this to mean that it couldn't find... well... process... not that it couldn't find the environment variable I was searching for