Support cors proxy #56
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Reference
gtfs.zone/deploy-gtfs-rt#56
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add a "Use CORS proxy" checkbox (checked by default) to two places: the "Load from URL" modal and the Atlas Search modal in coloring-book (gtfs.zone), and the Feed Configuration card in test-track (viz.rt.gtfs.zone) — covering both the static GTFS URL and all three realtime feed URL inputs. When checked, URLs are prefixed with
https://cors.gtfs.zone/before fetching. A clickable?link opens the MDN CORS guide in a new tab; a DaisyUI tooltip on that link explains what the proxy does and why it is usually needed.Relevant Context
coloring-book (
~/Documents/coloring-book)src/modules/ui.ts→showFromURLModal()(line 334): renders the "Load from URL" modal body as an HTML string passed toshowModal(). The checkbox + help link go here, below the URL input.src/modules/ui.ts→loadGTFSFromURL(url)(line 370): callsthis.gtfsParser!.parseFromURL(url). URL rewriting happens in theonClickhandler ofshowFromURLModalbefore calling this method.src/modules/atlas-search.ts→showAtlasSearchModal()(line 103): currently returnsstring | null. The checkbox goes inside this modal. Return type changes to{ url: string; useCors: boolean } | null.showAtlasSearchModalis insrc/modules/ui.ts(line ~120); applies the proxy prefix there before callingloadGTFSFromURL.src/modules/modal-utils.ts:showModal({ title, body, actions, onMount, enterAction, escapeAction }).bodyis an HTML string;onMount(close)is where DOM listeners are wired.src/index.htmllines 143–145):class="tooltip tooltip-bottom"+data-tip="..."on a wrapper element. The same element can also be the<a>tag or a wrapping<span>.checkbox checkbox-sm,label-text text-sm,btn btn-ghost btn-xs btn-circle.test-track (
~/Documents/test-track)src/index.htmllines 80–103: the "Static GTFS" section has<input id="static-gtfs-url" ...>followed by an "or Upload" row. Lines 107–138: the "Realtime Feeds" section has three URL inputs (#rt-vehicles-url,#rt-trip-updates-url,#rt-alerts-url). A single shared checkbox covers all four URLs.src/index.ts→loadFeeds()(line 44): reads all URL inputs and constructs feeds. URL rewriting for all four URLs happens here.src/gtfs-static.ts→loadFromUrl(url)(line 46): callsfetch(url)directly — no changes needed there.src/gtfs-rt.ts→GTFSRealtimeconstructor (line 13): acceptsvehicleUrl,tripUpdatesUrl,alertsUrlas plain strings — rewriting happens before construction inloadFeeds(); no changes needed ingtfs-rt.ts.Phases
Phase 1 — coloring-book: "Load from URL" modal
Goal: Add a checked-by-default CORS proxy checkbox with a
?help link to the existing URL modal, and route the URL through the proxy when checked.showFromURLModal()(src/modules/ui.tsline 337), extend thebodystring with a row below the URL input.onClickhandler, read the checkbox state and rewrite the URL.effectiveUrltothis.loadGTFSFromURL(effectiveUrl).Phase 2 — coloring-book: Atlas Search modal
Goal: Add the same checkbox to the Atlas Search modal so feeds selected from the atlas are also proxied when desired.
showAtlasSearchModal()(src/modules/atlas-search.tsline 108), add the same checkbox +?help link HTML below the search input (same snippet as Phase 1, reuseid="cors-proxy-checkbox").string | nullto{ url: string; useCors: boolean } | null.selectedUrlvariable to be{ url: string; useCors: boolean } | null.onSelect, capture checkbox state.src/modules/ui.ts(~line 120), apply proxy prefix.Phase 3 — test-track: Feed Configuration card
Goal: Add a single CORS proxy checkbox (covering all URL inputs — static and RT) to test-track's feed config card.
src/index.html, add the checkbox row after the divider between the Static GTFS and Realtime Feeds sections (line ~105).Note: RT endpoints must allow viz.rt.gtfs.zone via CORS.) since the proxy handles this now.src/index.ts→loadFeeds()(line 44), read the checkbox once and apply to all URLs via amaybeProxyhelper.Gotchas
https://cors.gtfs.zone/<original-url>— no URL encoding needed; the proxy reads the path directly.https://cors.gtfs.zone/.maybeProxyhelper keeps the rewriting DRY.class="tooltip tooltip-bottom"+data-tip="..."on the same element. Confirmed by usage insrc/index.htmllines 143–145.Support cors proxy in coloring-bookto Support cors proxy