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
Robert Jaros
11/22/2019, 9:59 AM
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
hellman
11/22/2019, 10:22 AM
Maybe something like this;
Copy code
val myVar = process.env["MY_VAR"]
s
shiraji
11/22/2019, 12:47 PM
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.