I have deployed a Nest js backend api on Vercel and it kinda working because I can see the home page after deployment, and I can send a get request to fetch all users for example, But I can't send a POST request to make a login and I get this CORS error in the console cors error I'm sure of my cors configurations is correct and that my API is working properly because I have deployed the backend on a different platform and it's working as it should and I don't get this cors error, I also have this vercel.json file:
{
"version": 2,
"name": "tasks-api",
"buildCommand": "npm start",
"installCommand": "npm install",
"regions": ["fra1"],
"builds": [
{
"src": "dist/main.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "dist/main.js",
"methods": ["GET", "POST", "PUT", "DELETE"]
}
]
}
and these some pics of the get request to fetch all users GET request: fetching all users GET request: fetching all users
I think the issue is related to the headers, but I just can't figure out the problem.
EDIT :
I just solved this problem by adding the dist folder to the repo as it turns out that Vercel needs this folder to be already there before deployment because it doesn't actually build your project files like a normal backend server.