From 8f89dc8e935c5c05ba242a5f64eba7c62854a705 Mon Sep 17 00:00:00 2001 From: Paul Norman Date: Sun, 30 Nov 2025 17:48:04 -0800 Subject: [PATCH] vectortile: make styles with absolute URLs available --- .../vectortile/templates/default/nginx.erb | 7 +++++++ .../vectortile/inspec/nginx_spec.rb | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/cookbooks/vectortile/templates/default/nginx.erb b/cookbooks/vectortile/templates/default/nginx.erb index 7a1bfe7a4..30e6cd616 100644 --- a/cookbooks/vectortile/templates/default/nginx.erb +++ b/cookbooks/vectortile/templates/default/nginx.erb @@ -58,5 +58,12 @@ server { # Add diagnostics header to identify render server add_header x-rendered-by "<%= node.name %>" always; } + location /styles/ { + proxy_pass http://demo; + proxy_http_version 1.1; + proxy_set_header Connection ""; + # Add diagnostics header to identify render server + add_header x-rendered-by "<%= node.name %>" always; + } root /srv/vector.openstreetmap.org/html; } diff --git a/test/integration/vectortile/inspec/nginx_spec.rb b/test/integration/vectortile/inspec/nginx_spec.rb index 75c1e16b8..dff02d334 100644 --- a/test/integration/vectortile/inspec/nginx_spec.rb +++ b/test/integration/vectortile/inspec/nginx_spec.rb @@ -24,3 +24,23 @@ end describe http("https://localhost", :ssl_verify => false) do its("status") { should cmp 200 } end + +describe http("https://localhost/styles/shortbread/colorful.json", :ssl_verify => false) do + its("status") { should cmp 200 } + its("headers") { should_not include "Access-Control-Allow-Origin" } + its("headers.vary") { should cmp "Origin" } +end + +describe http("https://localhost/styles/shortbread/colorful.json", :headers => { "Origin" => "https://www.openstreetmap.org" }, :ssl_verify => false) do + its("status") { should cmp 200 } + its("headers.Access-Control-Allow-Origin") { should cmp "https://www.openstreetmap.org" } + its("headers.vary") { should cmp "Origin" } +end + +describe json(:content => http("https://localhost/styles/shortbread/colorful.json", :ssl_verify => false).body) do + its(%w[sources versatiles-shortbread tiles]) do + should eq(["https://vector.openstreetmap.org/shortbread_v1/{z}/{x}/{y}.mvt"]) + end + its(["sprite", 0, "url"]) { should match %r{https://vector.openstreetmap.org/} } + its(["glyphs"]) { should match %r{https://vector.openstreetmap.org/} } +end -- 2.39.5