Skip to content
This repository was archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
improved support when using SSL/https.
Browse files Browse the repository at this point in the history
If X-Forwarded-Proto header is present use that value when constructing
URLs.

See #3
  • Loading branch information
Milan Andric committed Feb 28, 2015
1 parent 357f6e0 commit e315137
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ exports.upload_url = function (req) {


exports.app_db = function(req, path) {
var proto = 'http';
// If couchdb is behind a proxy use that protocol.
if (req.headers['X-Forwarded-Proto']) {
proto = req.headers['X-Forwarded-Proto'];
}
return url.format({
host: req.headers['Host'],
protocol: 'http',
protocol: proto,
pathname: path
});
}
Expand Down Expand Up @@ -174,4 +179,4 @@ exports.getDBURL = function(location){
var baseUrl = exports.getBaseURL(location);
console.log(baseUrl);
return baseUrl + '/_db';
}
}

0 comments on commit e315137

Please sign in to comment.