next.js with http-proxy-middleware post request file upload return 400 bad reqeust immediately

1k Views Asked by At
    const res = await axios({
      url: `http://localhost:3000/api/proxy/....`,
      method: "POST",
      headers: {
        "Content-Type": "mutipart/form-data",
      },
      data: formData,
      onUploadProgress: (progressEvent) => {
        const progress = Math.round((progressEvent.loaded * 100) / progressEvent.total);
        console.log(progress);
        handleProgress(progress);
      },
      withCredentials: true,
      timeout: 900000,
      timeoutErrorMessage: "Upload failed: Request time out 15 minutes",
    });

server: nest.js + nginx

Another request is fine (for example, get list, post json). but file upload request return 400 bad request immediately message is nginx html

nginx error.log

client send invalid method while reading client request line, clinent: ip, server: empty string, request: strange string(perhaps hex code.)
0

There are 0 best solutions below