From 38604c0a4525407a6a632ffe01ea2c748762b1d4 Mon Sep 17 00:00:00 2001 From: Monstrofil Date: Fri, 30 Sep 2022 16:18:13 +0300 Subject: [PATCH] Bugfix: publicUrl is not used in some urls (#605) 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. * Minor bugfix: make baseUrl always use '/' in the end Co-authored-by: Oleksandr Shyshatskyi Co-authored-by: acalcutt --- public/templates/wmts.tmpl | 8 ++++---- src/server.js | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/public/templates/wmts.tmpl b/public/templates/wmts.tmpl index 683c3ac84..0db7349c0 100644 --- a/public/templates/wmts.tmpl +++ b/public/templates/wmts.tmpl @@ -11,7 +11,7 @@ - + RESTful @@ -24,7 +24,7 @@ - + RESTful @@ -50,7 +50,7 @@ GoogleMapsCompatible - + GoogleMapsCompatible GoogleMapsCompatible EPSG:3857 @@ -403,5 +403,5 @@ 262144 - + diff --git a/src/server.js b/src/server.js index 38595784f..c00543845 100644 --- a/src/server.js +++ b/src/server.js @@ -420,7 +420,12 @@ export function server(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; });