fix(map): proxy all carto CDN requests to bypass CORS#19
Merged
Conversation
Carto CDN returns Access-Control-Allow-Origin with http:// instead of https://, blocking style, tile, sprite and glyph requests. Proxy all Carto URLs through Next.js rewrites via transformRequest so the browser makes same-origin requests only. Remove now-unused preconnect hints.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Production (
https://zipkit.app) 遭遇 Carto CDN 的 CORS 問題 -- CDN 回傳的Access-Control-Allow-Origin是http://zipkit.app(缺少 TLS),導致 style、tiles、sprites、glyphs 全部被瀏覽器阻擋。#18 只代理了 style.json,但 style 內部引用的 tile metadata、sprite、glyph 等資源也來自同樣的 Carto 網域,同樣被 CORS 阻擋。
此 PR 透過 Next.js rewrites + MapLibre
transformRequest將所有basemaps.cartocdn.com及tiles.basemaps.cartocdn.com請求代理到同源路徑/map-cdn/*,徹底繞過 CORS。同時移除不再需要的 preconnect hints。Test plan
pnpm dev-> Network tab 確認所有地圖請求走/map-cdn/...