#119 - Fixes support for proxy (X-Forwarded-Host header).

This commit is contained in:
Dan Peleg 2018-04-03 19:00:22 +03:00
parent a28df7ef8f
commit 83fa631981
3 changed files with 6 additions and 6 deletions

View file

@ -79,7 +79,7 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
query = '?' + queryParams.join('&');
}
return url.replace(
'local://', req.protocol + '://' + req.headers.host + '/') + query;
'local://', req.protocol + '://' + req.hostname + '/') + query;
};
var styleJSON_ = clone(styleJSON);

View file

@ -198,7 +198,7 @@ function start(opts) {
version: styleJSON.version,
name: styleJSON.name,
id: id,
url: req.protocol + '://' + req.headers.host +
url: req.protocol + '://' + req.hostname +
'/styles/' + id + '/style.json' + query
});
});
@ -298,7 +298,7 @@ function start(opts) {
var query = req.query.key ? ('?key=' + req.query.key) : '';
style.wmts_link = 'http://wmts.maptiler.com/' +
base64url('http://' + req.headers.host +
base64url('http://' + req.hostname +
'/styles/' + id + '.json' + query) + '/wmts';
var tiles = utils.getTileUrls(
@ -327,7 +327,7 @@ function start(opts) {
var query = req.query.key ? ('?key=' + req.query.key) : '';
data_.wmts_link = 'http://wmts.maptiler.com/' +
base64url('http://' + req.headers.host +
base64url('http://' + req.hostname +
'/data/' + id + '.json' + query) + '/wmts';
var tiles = utils.getTileUrls(

View file

@ -12,7 +12,7 @@ module.exports.getTileUrls = function(req, domains, path, format, aliases) {
if (domains.constructor === String && domains.length > 0) {
domains = domains.split(',');
}
var host = req.headers.host;
var host = req.hostname;
var hostParts = host.split('.');
var relativeSubdomainsUsable = hostParts.length > 1 &&
!/^([0-9]{1,3}\.){3}[0-9]{1,3}(\:[0-9]+)?$/.test(host);
@ -31,7 +31,7 @@ module.exports.getTileUrls = function(req, domains, path, format, aliases) {
domains = newDomains;
}
if (!domains || domains.length == 0) {
domains = [req.headers.host];
domains = [req.hostname];
}
var key = req.query.key;