I am getting cors error although i done with all the configuration in vercel.json file and handle in my main.ts file as well,
here is my code for vercel.json file
{
"version": 2,
"builds": [
{
"src": "dist/main.js",
"use": "@vercel/node"
}
],
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "Access-Control-Allow-Credentials", "value": "true" },
{ "key": "Access-Control-Allow-Origin", "value": "*" },
{ "key": "Access-Control-Allow-Methods", "value": "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
{ "key": "Access-Control-Allow-Headers", "value": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" }
]
}
],
"rewrites": [
{
"source": "/(.*)",
"destination": "/dist/main.js"
}
]
}
and here is my nestJS main.ts file
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import * as compression from 'compression';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: '*',
methods: '*',
allowedHeaders: '*',
preflightContinue: false,
optionsSuccessStatus: 204,
});
app.use(
compression({
filter: () => {
return true;
},
threshold: 0,
}));
await app.listen(3004);
}
bootstrap();