title: Using nodejs & expressjs: What's a good way of passing .env to html without templating?
body: <p>My html page makes an AJAX request to Node to get process.env. I do not have passwords or keys there. But, likely will need it in the future. Is there a secure way I can do this without templating?</p>
  
  <p>client-side</p>
  
  <pre><code>// source.html    
  $.get( "/env", function( data ) {console.log(data);});
  </code></pre>
  
  <p>Server side</p>
  
  <pre><code>// index.js
  app.get('/source', function(req, res){
    res.sendFile(__dirname + '/source.html');
  });
  
  app.get('/env', function(req, res) {
        res.send(process.env);
  });
  </code></pre>
  
  <p>I looked into EJS templating, but that seemed overkill for passing process.env as described in <a href="https://stackoverflow.com/questions/21955697/variables-between-node-js-server-and-client">Variables between Node.js Server and Client</a>.</p>
  
  <p>Ideas:</p>
  
  <ol>
  <li>App.get('/source', app.use(process.env.SOCKET_ADDR))? Am I overlooking an express route passing JS object option?</li>
  <li>Not clean, but I could make routes for environment variables individually rather than calling the whole object. On the same thought, make a new env object that contains no sensitive variables.</li>
  <li>Suck it up and template...</li>
  </ol>