-
Notifications
You must be signed in to change notification settings - Fork 7.4k
feat(map): add conflict KML overlay system with native WebGL rendering #2452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ahmadhamdan47
wants to merge
7
commits into
koala73:main
Choose a base branch
from
Ahmadhamdan47:feat/conflict-kml-overlay
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
616e50a
feat(map): add conflict KML overlay system with native WebGL rendering
Ahmadhamdan47 1ed2b05
fix(conflict-kml): address Greptile security and config review feedback
Ahmadhamdan47 6f36f33
Merge branch 'main' into feat/conflict-kml-overlay
Ahmadhamdan47 31b14b8
fix(tests): register gmaps-kml.js in legacy endpoint allowlist; updat…
Ahmadhamdan47 6d54a8f
Merge branch 'main' into feat/conflict-kml-overlay
Ahmadhamdan47 ec53d26
fix(conflicts): clarify KML folder translations description in Confli…
Ahmadhamdan47 7d87a7d
Merge branch 'main' into feat/conflict-kml-overlay
Ahmadhamdan47 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /** | ||
| * CORS proxy for Google My Maps KML exports. | ||
| * | ||
| * Usage: GET /api/gmaps-kml?url=<encoded-kml-url> | ||
| * | ||
| * Google My Maps KML exports are blocked by CORS when fetched from a browser | ||
| * directly. This Edge Function proxies the request server-side and returns the | ||
| * KML with permissive CORS headers so the client can parse it. | ||
| * | ||
| * Only Google Maps KML export URLs are accepted (allowlisted hostname) to | ||
| * prevent this endpoint from being used as an open proxy. | ||
| */ | ||
|
|
||
| import { checkRateLimit } from './_rate-limit.js'; | ||
|
|
||
| export const config = { runtime: 'edge' }; | ||
|
|
||
| const ALLOWED_HOSTNAMES = new Set(['www.google.com', 'maps.google.com']); | ||
|
|
||
| const CORS_HEADERS = { 'Access-Control-Allow-Origin': '*' }; | ||
|
|
||
| export default async function handler(req) { | ||
| if (req.method !== 'GET') { | ||
| return new Response('Method Not Allowed', { status: 405 }); | ||
| } | ||
|
|
||
| const rateLimitResponse = await checkRateLimit(req, CORS_HEADERS); | ||
| if (rateLimitResponse) return rateLimitResponse; | ||
|
|
||
| const { searchParams } = new URL(req.url); | ||
| const kmlUrl = searchParams.get('url'); | ||
|
|
||
| if (!kmlUrl) { | ||
| return new Response('Missing ?url= parameter', { status: 400 }); | ||
| } | ||
|
|
||
| let parsed; | ||
| try { | ||
| parsed = new URL(kmlUrl); | ||
| } catch { | ||
| return new Response('Invalid URL', { status: 400 }); | ||
| } | ||
|
|
||
| if (!ALLOWED_HOSTNAMES.has(parsed.hostname) || parsed.protocol !== 'https:') { | ||
| return new Response('URL not allowed', { status: 403 }); | ||
| } | ||
|
|
||
| const upstream = await fetch(kmlUrl, { | ||
| headers: { 'User-Agent': 'WorldMonitor/1.0' }, | ||
| }); | ||
|
|
||
| if (!upstream.ok) { | ||
| return new Response('Upstream fetch failed', { status: upstream.status }); | ||
| } | ||
|
|
||
| const kmlText = await upstream.text(); | ||
|
|
||
| return new Response(kmlText, { | ||
| status: 200, | ||
| headers: { | ||
| 'Content-Type': 'application/vnd.google-earth.kml+xml; charset=utf-8', | ||
| 'Cache-Control': 'public, max-age=300, s-maxage=600', | ||
| ...CORS_HEADERS, | ||
| }, | ||
| }); | ||
| } | ||
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.