One way is to insert the environment variable from the server into the global namespace on the client.
For example, if you did this in PHP:
<script>
var env = <?php echo $your_env_variable; ?>; // globally accessible variable
</script>
Now you can access this environment variable from any javascript files that are executed after this script tag.
In node, you would do the same, but with a template (e.g. Jade):
script(type='text/javascript').
var env = passedInEnvVar
source
share