Hi Netlify Support teams.
I have built a webapp by nextjs.
I’m running into an issue while waiting for an API response.
It seems that if the API response time exceeds 10 seconds, a 502 error will be raised.
When running a function using Netlify CLI, the same 10 second limit applies and will throw the same error as it does in production.
Is the API made from a Netlify function or the the path /api/* proxied to GCP? If it is proxied, then the response is not returned from Netlify (Netlify will return whatever is returned from the proxy endpoint.)
I just want to confirm that I understand correctly. I have created a file called ‘photographic.ts’ under the ‘/pages/api/’ folder, and in ‘photographic.ts’, I’m calling the real API that I have implemented in GCP. Does above work call “Proxy rewrites”?
Also, I have tested the API implemented from GCP on Postman and it works normally.
Does that mean the timeout of Proxy rewrites in nextjs is not 30 seconds?
Usually, the API takes 10-20 seconds to respond.
Thanks for the extra details. What you have described as I understand Next.js on Netlify is yes this is a function, not a rewrite/proxy.
This would mean the 10 second limit applies.
There is clearly a discrepancy between this test and the real-world deployed function. Is there perhaps an environment variable (e.g. API key) that is missing from the deploy? Have you tried adding logging to the function to see what is returned from the call or if the call is even made?
I am not a Next.js expert by any stretch of the imagination so I can’t guide you toward any specifics.