title: Next.js not setting NODE_ENV properly
body: <p>I am trying to run my cypress integration tests in a different NODE_ENV. The reason for this is because I want my tests to use a different api than the one used in development.</p>
  <p>Currently I'm setting the api url by checking the <code>NODE_ENV</code> and then setting the url that way.</p>
  <pre><code>if(process.env.NODE_ENV === 'development') {
      BASE_URL = 'http://localhost:3001' 
  } else {
      BASE_URL = 'https://api.example.com'
  }
  </code></pre>
  <p>When I start the Next server for the cypress tests, I set the NODE_ENV to test.</p>
  <pre><code>&quot;ci:start&quot;: &quot;set NODE_ENV='test' &amp; next start&quot;,
  &quot;ci&quot;: &quot;cypress run&quot;
  </code></pre>
  <p>Even after setting the <code>NODE_ENV</code>, it always shows up as &quot;development inside the app.</p>
  <p>I've also looked at the <a href="https://nextjs.org/docs/basic-features/environment-variables#test-environment-variables" rel="nofollow noreferrer">docs</a> and followed the instructions it has there. It says that:</p>
  <blockquote>
  <p>When running tests with tools like jest or cypress where you need to
  set specific environment vars only for testing purposes. Test default
  values will be loaded if NODE_ENV is set to test.</p>
  </blockquote>
  <p>However that is not the case as .env.local is still being loaded and the <code>NODE_ENV</code> does not change.</p>
  <p>Any help would be appreciated, thanks.</p>