I have a deployed Nextjs app on my Debian server with pm2, it work well, but when I set the Nginx reverse proxy to set the domain it have a error very specific.
So the backend and frontend work well, I have a POST endpoint here I can upload files(mostly image and pdf)if I do a POST without a file or a tiny file(I did some test and the limit is some close to .1m in the header lenght) this work well, but if I upload a larger file the endpoint doesn’t work.
I check the Nginx error logs and found it
Client timed out (110: Connection timed out) while waiting for request
The error only occurred when I use the app from the domain and not from the server ip.
export async function POST(req: Request) {
await connectMongoDB();
const contentLength = req.headers.get("content-length");
if (contentLength) {
console.log(`Request size: ${contentLength} bytes`);
} else {
console.log("Content-Length header is missing");
}
console.log("check0");
console.log("check0.1");
const data = await req.formData();
console.log("check1");
When the error ocurred I get a log
0|nextjs-a | Request size: 150198 bytes
0|nextjs-a | check0
0|nextjs-a | check0.1