Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy cannot handle large files #27

Closed
jdiehl opened this issue Jul 14, 2015 · 2 comments
Closed

Proxy cannot handle large files #27

jdiehl opened this issue Jul 14, 2015 · 2 comments

Comments

@jdiehl
Copy link

jdiehl commented Jul 14, 2015

Thanks for the great Express add-on!

When trying to send a large file through the proxy (more than 1 MB), an error event is thrown:

Error: request entity too large
at makeError (.../node_modules/express-http-proxy/node_modules/raw-body/index.js:184:15)
at module.exports (.../node_modules/express-http-proxy/node_modules/raw-body/index.js:40:15)
at handleProxy (.../node_modules/express-http-proxy/index.js:54:5)
at Layer.handle [as handle_request] (.../node_modules/express/lib/router/layer.js:82:5)
at trim_prefix (.../node_modules/express/lib/router/index.js:302:13)
at .../node_modules/express/lib/router/index.js:270:7
at Function.proto.process_params (.../node_modules/express/lib/router/index.js:321:12)
at next (.../node_modules/express/lib/router/index.js:261:10)
at serveStatic (.../node_modules/express/node_modules/serve-static/index.js:59:14)
at Layer.handle [as handle_request] (.../node_modules/express/lib/router/layer.js:82:5)

Could you use streams instead of reading the entire body into a buffer?

@Onigam
Copy link

Onigam commented Jul 23, 2015

You can specify the limit in the options:

exports.proxy = proxy(
    config.API_BASE_URL, {
        limit: "120mb",
        forwardPath: ...
    }
);

@jdiehl
Copy link
Author

jdiehl commented Jul 23, 2015

Thanks for the pointer - that will solve it for me for now.

It feels a little wrong though... A proxy should not load the entire request into a buffer and then send that buffer to the target. Instead the proxy should forward the stream as data arrives, making the process faster and less memory intensive. Do you think this would be possible to implement?

@jdiehl jdiehl closed this as completed Oct 19, 2015
Granjow added a commit to Granjow/express-http-proxy that referenced this issue Nov 9, 2016
This option can only be found in the code or in issue villadora#27 but is
quite important to know when using the proxy for large request.
monkpow pushed a commit that referenced this issue Nov 9, 2016
This option can only be found in the code or in issue #27 but is
quite important to know when using the proxy for large request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants