#CORS issue with Vue3 and Nest.js

7 messages · Page 1 of 1 (latest)

vivid cliff
#

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

paper chasm
#

There should be an OPTIONS request in your network tab 🤔

paper chasm
#

I think CloudFront is messing with your headers.

vivid cliff
#

sorry, do you mean this issue from API gateway or lambda?

#

this is a some logger from cloudwatch. I think there is no problem with AWS. cmiiw 🙏

spare pagoda
spare pagoda