2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

"request entity too large" の対応方法(Express.js, AWS Lambda)

Last updated at Posted at 2019-03-06

事象

AWS Lambda(Express.js)で引数有りの関数を呼び出すと、エラー"request entity too large"が発生。

原因

ミドルウェア"body-parser"で引数のサイズ制限が設定されているため。

bodyParser.raw([options])
(中略)
Options
The text function takes an optional options object that may contain any of the following keys:
(中略)
limit
Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a string, the value is passed to the bytes library for parsing. Defaults to '100kb'

対応方法

app.ts
// 制限サイズを増やす
app.use(bodyParser.urlencoded({ limit:'50mb',extended: true }));

// jsonメソッドに対しても制限サイズを設定する
app.use(bodyParser.json({limit: "50mb"}));

感想

最初、AWS Lambdaの環境設定を疑ったが、全然違った。

参照

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?