Skip to content
This repository has been archived by the owner on Jan 4, 2018. It is now read-only.

Commit

Permalink
feat: CORSPROXY_MAX_PAYLOAD option (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
rocwind authored and gr2m committed Sep 26, 2016
1 parent d3d5340 commit 81dcc27
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion bin/corsproxy
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {})
Expand Down Expand Up @@ -44,6 +45,11 @@ proxy.route({
callback(null, 'http://' + request.host + request.path + query, request.headers)
}
}
},
config: {
payload: {
maxBytes: maxPayload
}
}
})

Expand Down Expand Up @@ -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)
})

0 comments on commit 81dcc27

Please sign in to comment.