From 2d9e2f7f4e268f3590ef3387ee5efa77ab7353e2 Mon Sep 17 00:00:00 2001 From: Oleksandr Shyshatskyi Date: Thu, 15 Sep 2022 20:23:48 +0300 Subject: [PATCH] Improved publicUrl option support In WMTS the publicUrl path was missed and it was not working properly. Similar story about wmts.tmpl: the baseUrl is not working properly when tileserver is hidden behind the proxy with different root path. --- public/templates/index.tmpl | 2 +- src/server.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/public/templates/index.tmpl b/public/templates/index.tmpl index 603f2eb..297520e 100644 --- a/public/templates/index.tmpl +++ b/public/templates/index.tmpl @@ -41,7 +41,7 @@ {{#if serving_data}}| {{/if}}TileJSON {{/if}} {{#if serving_rendered}} - | WMTS + | WMTS {{/if}} {{#if xyz_link}} | XYZ diff --git a/src/server.js b/src/server.js index 9fedc02..70180d7 100644 --- a/src/server.js +++ b/src/server.js @@ -419,7 +419,12 @@ function start(opts) { } wmts.id = id; wmts.name = (serving.styles[id] || serving.rendered[id]).name; - wmts.baseUrl = `${req.get('X-Forwarded-Protocol') ? req.get('X-Forwarded-Protocol') : req.protocol}://${req.get('host')}`; + if (opts.publicUrl) { + wmts.baseUrl = opts.publicUrl; + } + else { + wmts.baseUrl = `${req.get('X-Forwarded-Protocol') ? req.get('X-Forwarded-Protocol') : req.protocol}://${req.get('host')}`; + } return wmts; });