Support local:// raster tile URLs

In the style JSON configuration, allow to use the local://
pseudo-protocol prefix also for raster tile source URLs. When serving
the style JSON, rewrite it into an absolute URL using the public URL or
the Host header from the request.

This allows to use raster tile sources which are served from the same
domain, but externally from tileserver-gl. The requests could be handled
by a reverse proxy in front of tileserver-gl for example, and redirected
to a different service or static files.

Instead of hardcoding an absolute host name in the style configuration,
using a relative URL allows to use the same style configuration on
different hosts and on localhost in the development environment.
This commit is contained in:
Hermann Schwarting 2020-06-16 11:12:08 +02:00
parent a5a8ae1e95
commit 13c481b1ea

View file

@ -40,6 +40,9 @@ module.exports = {
for (const name of Object.keys(styleJSON_.sources)) {
const source = styleJSON_.sources[name];
source.url = fixUrl(req, source.url, item.publicUrl);
if (source.tiles) {
source.tiles = source.tiles.map(url => fixUrl(req, url, item.publicUrl))
}
}
// mapbox-gl-js viewer cannot handle sprite urls with query
if (styleJSON_.sprite) {