Next.js Discord

Discord Forum

405 error on live website (host on Vercel)

Unanswered
Highlander posted this in #help-forum
Open in Discord
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?

12 Replies

405 means method is not allowed so GET, POST OPTIONS are not configured correctly in the Express server. check cors settings in express
check chrome dev tool network as well
it tells a lot
@tafutada777 405 means method is not allowed so GET, POST OPTIONS are not configured correctly in the Express server. check cors settings in express
HighlanderOP
Thanks for your answer but I already know about 405 error and check all my server configs. This is why I am here, to see if someone could not solved this issue even though I got the right configs.
so what exactly did you get in chrome dev tool network?
HighlanderOP
I was looking more into depth and I can see Vercel has some conventions to follow if I want to use /api for requests as a standalone
I added index.ts to redirect my traffic
and a vercel.json file to rewrites it
now I get this error
Error: The file "/vercel/path0/.next/routes-manifest.json" couldn't be found. This is often caused by a misconfiguration in your project.
yes. Vercel uses AWS lambda and Cloudflare Worker and split codes into instances automagically. but you need to use Next.js to get the magic.