Everything runs fine locally when I run netlify dev, but when I deploy to production I get a 502 error. I have checked my database and everything is getting updated properly in there when I visit different routes in my app. Cookies are even getting set in the browser, but the response from the server is returning a 502 error even though the response times are well below 10 seconds.
IMPORTANT NOTE: The database that I am using right now is a development database and it goes to sleep after about 30 minutes of inactivity and then it takes about 30 to 60 seconds to wake up after it receives a request. So the initial response will probably time out for you, but after the database is awake then the functions respond under 10 seconds.
Hi @samwell, first, I noticed you’re using no-cache for cache-control, if the idea is to make sure the funciton is hit every time and the response from it isn’t just cached, you should instead use no-store instead.Also, make sure your functions are returning valid JSON, and not just a boolean value or a number(I don’t know if you are returning a number anywhere, just wanted to make sure you know this).
Hey @samwell, were you able to find a solution for this? Facing a similar issue now where I get a 502 Bad Gateway in production even though response time is less than a second. Works fine locally.