Skip to content

Commit

Permalink
Merge pull request #1642 from nfl/bugfix/https-protocol
Browse files Browse the repository at this point in the history
fix (proxy): Pass protocol in target object to enable https requests.
  • Loading branch information
dignifiedquire committed Oct 20, 2015
2 parents 9aceea1 + 142db90 commit b138619
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/middleware/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var parseProxyConfig = function (proxies, config) {
}

var hostname = proxyDetails.hostname || config.hostname
var protocol = proxyDetails.protocol || config.protocol
var port = proxyDetails.port || config.port ||
(proxyDetails.protocol === 'https:' ? '443' : '80')
var https = proxyDetails.protocol === 'https:'
Expand All @@ -43,7 +44,8 @@ var parseProxyConfig = function (proxies, config) {
target: {
host: hostname,
port: port,
https: https
https: https,
protocol: protocol
},
xfwd: true,
secure: config.proxyValidateSSL
Expand Down
16 changes: 15 additions & 1 deletion test/unit/middleware/proxy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe('middleware.proxy', () => {
expect(parsedProxyConfig[0].proxy).to.exist
})

it('should set defualt https port', () => {
it('should set default https port', () => {
var proxy = {'/base/': 'https://localhost/'}
var parsedProxyConfig = m.parseProxyConfig(proxy, {})
expect(parsedProxyConfig).to.have.length(1)
Expand All @@ -178,6 +178,13 @@ describe('middleware.proxy', () => {
https: true
})
expect(parsedProxyConfig[0].proxy).to.exist
expect(parsedProxyConfig[0].proxy).to.containSubset({
options: {
target: {
protocol: 'https:'
}
}
})
})

it('should handle proxy configs with paths', () => {
Expand Down Expand Up @@ -206,6 +213,13 @@ describe('middleware.proxy', () => {
https: true
})
expect(parsedProxyConfig[0].proxy).to.exist
expect(parsedProxyConfig[0].proxy).to.containSubset({
options: {
target: {
protocol: 'https:'
}
}
})
})

it('should handle proxy configs with only basepaths', () => {
Expand Down

0 comments on commit b138619

Please sign in to comment.