I try to set up cors for my Nestjs like this,
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: '*',
allowedHeaders:
'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept, Observe',
methods: 'GET,PUT,POST,DELETE,UPDATE,OPTIONS',
credentials: true,
});
and deployed to AWS lambda with a Serverless framework.
When I'm trying to hit the API from my production client (VUE 3) with Axios, I always get this issue
Access to XMLHttpRequest at 'https://0l89uhx5f4.execute-api.ap-southeast-1.amazonaws.com/dev/users' from origin 'https://toys-survey-frontend-nestjs.vercel.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I try to google to solve this issue, but not yet found a solution for this.
Does anyone have some clue about this case?
any idea will be very appreciated.
thank you & have a good day