GAE 中 Node JS 项目中的 HTTP 413 请求实体太大

Sap*_*Dey 3 google-app-engine json nginx node.js body-parser

我在 GAE 上部署了我的后端应用程序。在其中,我有一个 API,它将文件上传到 GCS 存储桶。最近我尝试上传超过 50mb 的文件并得到413 Request entity too large

做了一些研究,发现问题出在ngnix. API 将提供413大于 32Mb 的任何文件。

找到一个解决方案,其中提到包含ngnix.conf文件并添加client_max_body_size 80M到其中。我这样做了,但仍然得到同样的错误。

这是我的ngnix-app.conf文件

server{
 location / {
        client_max_body_size       80m;
        client_body_buffer_size    512k;
  }
}
Run Code Online (Sandbox Code Playgroud)

有什么明显的东西让我错过了吗?

Kar*_*a S 8

您可以使用以下命令更改 Node.Js 应用程序中的请求缓冲区大小

app.use(bodyParser.json({limit: '50mb'})); 
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
Run Code Online (Sandbox Code Playgroud)

您也可以在 nginx 配置中增加您的请求

server{
 location / {
        client_max_body_size       xxm;
        client_body_buffer_size    xxm;
  }
}
Run Code Online (Sandbox Code Playgroud)