I understand I can use web.config.
<iisnode
node_env="production"
/>
to specify one environmental node_env
variable which could be accessed in server side *.js files via process.env.node_env
.
However, for example I would like to have access to another environmental variable like
process.env.GLOBAL_PREFIX
. Similar scenarios like access to AWS credentials.
When I tried
<iisnode
node_env="production"
GLOBAL_PREFIX="somevalue"
/>
, I could not get application running due to unrecognized web.config file.
To set system-wide Linux environment variables, you can edit the /etc/environment file. Instead of appending export commands to the file, append the <NAME>='<VALUE>' pair to the end of the file.
Press the Windows key + X to access the Power User Task Menu. In the Power User Task Menu, select the System option. Click the Advanced System Settings link in the left column. In the System Properties window, click the Advanced tab, then click the Environment Variables button near the bottom of that tab.
IISNode exposes any keys specified in your <appSettings>
to the process.env
object.
If you want to access GLOBAL_PREFIX
in your Node app just do this
Web.Config
<configuration>
<appSettings>
<add key="GLOBAL_PREFIX" value="somevalue" />
</appSettings>
Server.js
var globalPrefix = process.env.GLOBAL_PREFIX;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With