Even Simple Next.js API timeout on Vercel
Unanswered
English Angora posted this in #help-forum
English AngoraOP
Every apis in the NextJS project is giving a 504 bad gateway time out error only in vercel production deployment, everithing works fine in local, so i added a hello GET api with the sample code
but this does fail too with 504
504: GATEWAY_TIMEOUT Code: FUNCTION_INVOCATION_TIMEOUT
this is the link https://glomium-dashboard.vercel.app/api/hello/
When i checked the vercel log the apis sometimes rarely works for once and then starts to fail with 504 again.
My code is located at src\pages\api in the root
export default function handler(req, res) {
res.status(200).json({ message: 'Hello from Next.js!' })
}but this does fail too with 504
504: GATEWAY_TIMEOUT Code: FUNCTION_INVOCATION_TIMEOUT
this is the link https://glomium-dashboard.vercel.app/api/hello/
When i checked the vercel log the apis sometimes rarely works for once and then starts to fail with 504 again.
My code is located at src\pages\api in the root
5 Replies
Alapaha Blue Blood Bulldog
it seems working, tried refreshing many times.
Are you using pages or app route.
Are you using pages or app route.
@Alapaha Blue Blood Bulldog it seems working, tried refreshing many times.
Are you using pages or app route.
it was not working for me too. look like vercel had some issue and got fixed now
@Ray it was not working for me too. look like vercel had some issue and got fixed now
Alapaha Blue Blood Bulldog
May be. Many issues right now on vercel. In my app, trying to login refreshes the login page, it was working correctly 2 days ago. Thought it was problem on my code and deployed on another server, works correctly there, but only in vercel.
@Alapaha Blue Blood Bulldog it seems working, tried refreshing many times.
Are you using pages or app route.
English AngoraOP
Yeah, it started working when i changed the node version from v18 to v20. but when i hit the api today morning it still shown the 504 error on the first attemp and then after that it started working again. i don't know what is happening.
@Alapaha Blue Blood Bulldog May be. Many issues right now on vercel. In my app, trying to login refreshes the login page, it was working correctly 2 days ago. Thought it was problem on my code and deployed on another server, works correctly there, but only in vercel.
English AngoraOP
Do you try to change the serverless function location?