7

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.

peteb
  • 18,552
  • 9
  • 50
  • 62
Bowei Liu
  • 161
  • 1
  • 9

1 Answers1

20

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;
peteb
  • 18,552
  • 9
  • 50
  • 62