I've a nextjs project proxied by nginx. I'm consuming a rest api served by nextjs itself that takes more than 2 minutes.
First error I get was 504 timeout by nginx so I added some additional directives:
proxy_connect_timeout 600s;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
Then the error code becomes 502. Looking at proxy_error_log file the error is
upstream prematurely closed connection while reading response header from upstream.
In my project I'm not using express or any other server explicitly so I don't know how to set http server timeout. Any way to set timeout from next.config.js file or globally for node js?