I\'ve enabled CORS in my NestJS app following the official tutorial, so my main.ts
looks like the following:
import { FastifyAdapter, NestFactory }
Sad to know that you also tried:
const app = await NestFactory.create(ApplicationModule);
app.enableCors();
await app.listen(3000);
And it's still not working.
Ensure that on your server side you have cors enabled, which should be something like this:
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type, Accept');
next();
});
And also ensure that your browser is cors supported. If all these still doesn't work, I will advice you download Allow-Control-Allow-Origin extension for Chrome, it should fix your issue.