mirror of https://github.com/calzoneman/sync.git
Respect X-Forwarded-Proto if it is set
This commit is contained in:
parent
a405c2c5fa
commit
91d81c4367
|
@ -16,7 +16,7 @@ function merge(locals, res) {
|
|||
loginDomain: Config.get("https.enabled") ? Config.get("https.full-address")
|
||||
: Config.get("http.full-address"),
|
||||
csrfToken: res.req.csrfToken(),
|
||||
baseUrl: res.req.protocol + "://" + res.req.header("host")
|
||||
baseUrl: getBaseUrl(res)
|
||||
};
|
||||
if (typeof locals !== "object") {
|
||||
return _locals;
|
||||
|
@ -27,6 +27,18 @@ function merge(locals, res) {
|
|||
return _locals;
|
||||
}
|
||||
|
||||
function getBaseUrl(res) {
|
||||
var req = res.req;
|
||||
var proto;
|
||||
if (["http", "https"].indexOf(req.header("x-forwarded-proto")) >= 0) {
|
||||
proto = req.header("x-forwarded-proto");
|
||||
} else {
|
||||
proto = req.protocol;
|
||||
}
|
||||
|
||||
return proto + "://" + req.header("host");
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders and serves a jade template
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue