title: CORS blocking fetch function on Nestjs(server) and Vuejs(client) on localhost
body: <p>im try to learn to build my own RestAPI by using node and nest js.
  everything works fine, tested on POSTMAN: it works.</p>
  <p>but when i tried to fetch it from my frontend, it being blocked by CORS.
  although i have enabled the cors setting on Nestjs.</p>
  <pre><code>import { AppModule } from './app.module';
  
  async function bootstrap() {
    const app = await NestFactory.create(AppModule);
    app.enableCors();
    await app.listen(3000);
  }
  bootstrap();
  </code></pre>
  <p>and calling it from VueJS:</p>
  <pre><code>postPackageToServer: function () {
    var myHeaders = new Headers();
    myHeaders.append(&quot;Content-Type&quot;, &quot;application/json&quot;);
  
        var raw = JSON.stringify({
          type: &quot;monthly&quot;,
          price: 30,
          startDate: &quot;04-08-2020&quot;,
          endDate: &quot;06-08-2020&quot;,
        });
  
        var requestOptions = {
          method: &quot;POST&quot;,
          headers: myHeaders,
          body: raw,
          redirect: &quot;follow&quot;,
        };
  
        let postData = async() =&gt; {
          let postingDating = await fetch(&quot;localhost:3000/vouchers&quot;, requestOptions)
          .then((response) =&gt; response.text())
          .then((result) =&gt; console.log(result))
          .catch((error) =&gt; console.log(&quot;error&quot;, error));
        }
      },
  </code></pre>
  <p>may i know what i did wrong? and how to fix it.
  if this issue has been answered by other question, i would love to learn from it.</p>
  <p>thank you</p>