title: Gatsby .env.production variables - undefined
body: <p>When building a Gatsby project I'm getting all <code>env</code> variables <code>undefined</code> in <code>production</code> environment.
  In <code>development</code> everything is fine.
  I have 2 similar <code>.env.development</code> and <code>.env.production</code> files.</p>
  
  <p>In my <code>gatsby-config.js</code> I have </p>
  
  <pre><code>require('dotenv').config({
    path: `.env.${process.env.NODE_ENV}`,
  });
  </code></pre>
  
  <p>and if I <code>console.log(process.env.NODE_ENV)</code> during <code>gatsby build</code> it gives <code>production</code> and the variables can be accessed and logged out.
  But later in code something like </p>
  
  <pre><code>return request.post(`${process.env.GEOCODING_CF_URL}/latlng`, {...});
  </code></pre>
  
  <p>gives request to <code>http://localhost:9000/ru/undefined/latlng</code>.</p>
  
  <p>What am I doing wrong and how this issue can be fixed?</p>
  
  <p>UPDATE:</p>
  
  <p>When I run <code>gatsby build</code> - <code>process.env.NODE_ENV</code> is <code>production</code></p>
  
  <p>When I run <code>gatsby serve</code> - <code>process.env.NODE_ENV</code> is <code>undefined</code></p>
  
  <p>If this can help in any way. </p>