Next.js Discord

Discord Forum

405 CORS error on website online (Vercel)

Unanswered
Highlander posted this in #help-forum
Open in Discord
Avatar
HighlanderOP
My app is a React app using Express and Node JS server to call MongoDB online database. I host on Vercel. There is no problems except I cannot fetch any queries. I checked my express configuration, my next.config, I even added vercel.json with the cors configs.
my server config is :
const corsOptions = {
origin: 'https://example-beryl.vercel.app',
};
app.use(cors(corsOptions));
and my fetch query is using the url : const url = https://example-beryl.vercel.app/api/items .
My code works in localhost but not on live version.

My API call is like router.post('/', async (req, res) => { code here...})

I was wondering what's the issue?

0 Replies