How to Change body parser limit in Firebase?
Asked Answered
N

1

7

I'm trying to proxy a file upload to firebase cloud functions to not expose our API url.

Seems like Firebase is using Body-parser under the hood to parse body in the requests but it's limited to 100kb by default.

I've tried this: var bodyParser = require('body-parser'); app.use(bodyParser.json({limit: '50mb'})); app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));

but it seems it's not using that bodyParser. It's using a private one embedded into Firebase's framework. Is there a way to change the limit on it?

This is what I'm getting:

Blockquote error: { Error: request entity too large at readStream (/usr/local/lib/node_modules/firebase-tools/node_modules/raw-body/index.js:196:17) at getRawBody (/usr/local/lib/node_modules/firebase-tools/node_modules/raw-body/index.js:106:12) at read (/usr/local/lib/node_modules/firebase-tools/node_modules/body-parser/lib/read.js:76:3) at urlencodedParser (/usr/local/lib/node_modules/firebase-tools/node_modules/body-parser/lib/types/urlencoded.js:115:5) at Layer.handle [as handle_request] (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/router/index.js:317:13) at /usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/router/index.js:335:12) at next (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/router/index.js:275:10) at textParser (/usr/local/lib/node_modules/firebase-tools/node_modules/body-parser/lib/types/text.js:78:7) at Layer.handle [as handle_request] (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/router/index.js:317:13) at /usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/router/index.js:335:12) at next (/usr/local/lib/node_modules/firebase-tools/node_modules/express/lib/router/index.js:275:10) at rawParser (/usr/local/lib/node_modules/firebase-tools/node_modules/body-parser/lib/types/raw.js:76:7) expected: 611961, length: 611961, limit: 102400, message: 'request entity too large', status: 413, statusCode: 413, type: 'entity.too.large' } Blockquote

Nab answered 3/8, 2017 at 16:25 Comment(0)
F
0

Do you also use: app.use(express.json())? If you also use this middleware, express.json() has a limit of 100kb, you should try without it.

Flambeau answered 14/1, 2021 at 12:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.