From 81dcc2710bd399c1e762fd968f8ee07c4165e1cc Mon Sep 17 00:00:00 2001 From: Roc Date: Mon, 26 Sep 2016 11:24:37 +0800 Subject: [PATCH] feat: CORSPROXY_MAX_PAYLOAD option (#47) --- .travis.yml | 4 ++-- README.md | 1 + bin/corsproxy | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c8447c1..b60b42e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,9 @@ cache: notifications: email: false node_js: - - '4' + - '6' before_install: - - npm i -g npm@^2.0.0 + - npm i -g npm@^3.0.0 - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start script: TEST_CLIENT=selenium:firefox npm test diff --git a/README.md b/README.md index 97d3354..02fb348 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ corsproxy # with custom port: CORSPROXY_PORT=1234 corsproxy # with custom host: CORSPROXY_HOST=localhost corsproxy # with debug server: DEBUG=1 corsproxy +# with custom payload max bytes set to 10MB (1MB by default): CORSPROXY_MAX_PAYLOAD=10485760 corsproxy ``` ## Usage diff --git a/bin/corsproxy b/bin/corsproxy index acf0b22..c82f3a5 100755 --- a/bin/corsproxy +++ b/bin/corsproxy @@ -8,6 +8,7 @@ var loggerOptions = require('../lib/logger-options') var server = new Hapi.Server({}) var port = parseInt(process.env.CORSPROXY_PORT || process.env.PORT || 1337, 10) var host = (process.env.CORSPROXY_HOST || 'localhost'); +var maxPayload = parseInt(process.env.CORSPROXY_MAX_PAYLOAD || 1048576, 10) var proxy = server.connection({ port: port, labels: ['proxy'], host: host}) server.register(require('inert'), function () {}) @@ -44,6 +45,11 @@ proxy.route({ callback(null, 'http://' + request.host + request.path + query, request.headers) } } + }, + config: { + payload: { + maxBytes: maxPayload + } } }) @@ -110,5 +116,5 @@ if (process.env.DEBUG) { server.start(function (error) { if (error) server.log('error', error) - server.log('info', 'CORS Proxy running at: ' + server.info.uri) + server.log('info', 'CORS Proxy running at: ' + proxy.info.uri) })