I am using a nextjs frontend, and a nestjs backend. Frontend it deployed on vercel and…
- User
I am using a nextjs frontend, and a nestjs backend. Frontend it deployed on vercel and the backend on railway. When calling the backend endpoint from the frontend I'm getting a cors error
- Assistant
To fix the CORS error, you need to enable CORS on your NestJS backend. Here is how you can do it:
-
First, make sure you have the
@nestjs/platform-expresspackage installed. If you don't, install it using NPM or Yarn:codenpm install @nestjs/platform-expressor
codeyarn add @nestjs/platform-express -
Now, open your
main.tsfile in your NestJS backend project.
-