Hi, I have a question about KotlinJS. How can I se...
# javascript
s
Hi, I have a question about KotlinJS. How can I set environment variables? I tried followings: • adding .env file • setting variables in gradle • using webpack define plugin To read the variables, I used
process.env.MY_VAR
. I managed to see
process.env
but not
process.env.MY_VAR
r
It's all about your environment not the language itself. If you run your code in the browser, you will not be able to access environment variables at all (for security reasons). If you execute it in Node.js,
process.env
should work.
h
Maybe something like this;
Copy code
val myVar = process.env["MY_VAR"]
s
val myVar = process.env["MY_VAR"]
It seems not work to my environment. Well, what I want to do is changing API URL based on the environment. Maybe using environment variable is not good for this purpose.