Skip to content

Commit

Permalink
Add HTTPS option
Browse files Browse the repository at this point in the history
  • Loading branch information
tehelsper authored Jun 17, 2020
1 parent 45952b5 commit e3ed248
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/corsproxy
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ var Hapi = require('hapi')
var plugin = require('../index')
var good = require('good')
var loggerOptions = require('../lib/logger-options')
var fs = require('file-system')

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 target = (process.env.CORSPROXY_TARGET || null);
var maxPayload = parseInt(process.env.CORSPROXY_MAX_PAYLOAD || 1048576, 10)
var proxy = server.connection({ port: port, labels: ['proxy'], host: host})
var options = {port: port, labels: ['proxy'], host: host}
if (process.env.CORSPROXY_USE_HTTPS) {
var tls = {
key: fs.readFileSync(process.env.CORSPROXY_HTTPS_KEY),
cert: fs.readFileSync(process.env.CORSPROXY_HTTPS_CERT)
};
options = {port: port, labels: ['proxy'], tls: tls, host: host}
}
var proxy = server.connection(options)

server.register(require('inert'), function () {})
server.register(require('h2o2'), function () {})
Expand Down

0 comments on commit e3ed248

Please sign in to comment.