go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.28k stars 194 forks source link

vu app not taking uri_prefix into account (was uri_prefix not working on versions > 0.13.0) #904

Closed JackMcKew closed 6 months ago

JackMcKew commented 1 year ago

I've been recently trying to upgrade from version 0.13.0 to 0.16.0. My use case depends on the uri_prefix because I'm using a proxy via an ingress in Kubernetes.

My config looks like

[webserver]
port = ":80"
uri_prefix = "/public/map-tile-server-tegola"

[cache]
type = "s3"
bucket = "map-tiles-cache"
basepath = "staging"
region = "ap-southeast-2"
aws_access_key_id = "${AWS_S3_MAP_TILES_CACHE_USER_ACCESS_KEY_ID}"
aws_secret_access_key = "${AWS_S3_MAP_TILES_CACHE_USER_SECRET_ACCESS_KEY}"

[[providers]]
name = "map_tiles"
type = "mvt_postgis"
uri = "postgresql://${AWS_AURORA_MAP_TILES_DB_USERNAME}:${AWS_AURORA_MAP_TILES_DB_PASSWORD}@${AWS_AURORA_MAP_TILES_DB_HOST}:${AWS_AURORA_MAP_TILES_DB_PORT}/${AWS_AURORA_MAP_TILES_DB_DATABASE}?default_transaction_read_only=false&pool_max_conn_idle_time=5"
srid = 4_326

    [[providers.layers]]
      name = "activity-heatmap"
      geometry_fieldname = "geom"
      id_fieldname = "ogc_fid"
      sql = "SELECT ogc_fid, url, texttodisplay, icontoshow, count, ST_AsMVTGeom(ST_Multi(wkb_geometry),!BBOX!) AS geom FROM map_tiles.source_layers WHERE \"layer\" = 'activity_heatmap' AND wkb_geometry && !BBOX!"

[[maps]]
name = "map_tiles"

  [[maps.layers]]
  provider_layer = "map_tiles.activity-heatmap"
  min_zoom = 11
  max_zoom = 11

When I spin this up locally using the following Dockerfile:

FROM gospatial/tegola:v0.13.0 as builder
EXPOSE 80

COPY file-store/tegola-config /opt/tegola_config

CMD ["serve", "--config=/opt/tegola_config/config.toml"]

On versions 0.13.0+, I can reach localhost/public/map-tile-server-tegola/capabilities, the json returns as expected. However, if I head to localhost/public/map-tile-server-tegola, all I see is 404 responses.

On version 0.13.0, this shows the viewer as expected.

Let me know if you can't reproduce this issue

iwpnd commented 1 year ago

Hey! Any chance this is because of that botched SRID in the provider config?

JackMcKew commented 1 year ago

Hey 👋

The underscores in the SRID don't make a difference

https://toml.io/en/v1.0.0

iwpnd commented 1 year ago

The underscores in the SRID don't make a difference

today I learned it also is supported in toml

Let me go ahead and try to reproduce the issue

update:

yup, reproducible. However, this "only" affects the viewer. Tiles are served correctly at:

http://localhost:8080/public/map-tile-server-tegola/maps/map_tiles/{z}/{x}/{y}.pbf

I don't really see why this would happen, as the viewer endpoints are attached to the same group as all the other endpoints.

JackMcKew commented 1 year ago

Ah awesome, at least the tiles are still being served correctly, was throwing me down all sorts of rabbit holes

I'll leave this issue open as it definitely affected me

ARolek commented 1 year ago

@iwpnd did you find the root cause of this issue? I will need to look through the commit log to figure out when this change occurred.

iwpnd commented 1 year ago

i did not go down the rabbithole just yet, nope

update: while you can point the http.FS of the built viewer to whatever uri_prefix you like, the vuejs app itself is using / as apiRoot. So when the app is starting and trying to collect information from /capabilities although your capabilities are at /my_prefix/capabilities, the catch statement is printing the resulting 404. So I think this is an issue with the vuejs app, rather than tegola server.