NestJS enable cors in production : <p>I've enabled CORS in my NestJS app following <a href="https://docs.nestjs.com/techniques/cors" rel="noreferrer">the official tutorial</a>, so my <code>main.ts</code> looks like the following:</p>

<pre><code>import { FastifyAdapter, NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(AppModule, new FastifyAdapter(), { cors: true });
  await app.listen(3000);
}
bootstrap();
</code></pre>

<p>and it works when I run the application using <code>npm run start:dev</code>.</p>

<p>However when I try to first compile the application using <code>npm run webpack</code> and then running it using <code>node server.js</code>, the cors will not work.</p>

<p>The http request from the client will fail with:</p>

<blockquote>
  <p>Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://localhost:8000" rel="noreferrer">http://localhost:8000</a>' is therefore not allowed access. The response had HTTP status code 404.</p>
</blockquote>
