Fix #3: drop broken CORS proxy, use MediaWiki API directly#4
Open
fredrik-lindseth wants to merge 1 commit intoosmno:mainfrom
Open
Fix #3: drop broken CORS proxy, use MediaWiki API directly#4fredrik-lindseth wants to merge 1 commit intoosmno:mainfrom
fredrik-lindseth wants to merge 1 commit intoosmno:mainfrom
Conversation
The Cloudflare Worker proxy at production.osmno-cors-proxy.mathiash98.workers.dev forwards a gzipped upstream body without setting Content-Encoding: gzip, so browsers fail with ERR_CONTENT_DECODING_FAILED on every progress page (see osmno#3). Drop the proxy entirely. Both data sources already serve CORS: - wiki.openstreetmap.org exposes the MediaWiki action API with origin=* (Access-Control-Allow-Origin: *). Use action=parse&prop=text and pull the rendered HTML from parse.text["*"]. - obtitus.github.io is GitHub Pages, which sends Access-Control-Allow-Origin: * for static files. Fetch directly. This removes a single point of failure hosted on a personal Cloudflare account and shortens the request path.
Open
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.
Closes #3.
Diagnose
CORS-proxyen
production.osmno-cors-proxy.mathiash98.workers.dev(Cloudflare Worker) returnerer gzip-komprimert body men sender ikke medContent-Encoding: gzip-header. Browseren serContent-Type: text/htmlog prøver å parse rå gzip-bytes som tekst →ERR_CONTENT_DECODING_FAILEDpå alle datasett.Bekreftet ved å lagre svaret rått:
Body er gzip, men ingen
content-encoding-header i responsen.Løsning
Begge datakildene serverer allerede CORS-headere selv — proxyen er overflødig:
wiki.openstreetmap.org/w/api.php?...&origin=*access-control-allow-origin: *obtitus.github.io/...(GitHub Pages)access-control-allow-origin: *For wiki bruker vi MediaWiki action API (
action=parse&prop=text&format=json&origin=*) og henter rendret HTML fraparse.text["*"]. For andre hostnavn (per nå kunobtitus.github.io) henter vi siden direkte.Fordeler:
Test
Kjørt lokalt mot
http://localhost:8765/?project=ssr(og verifisert medcurlfor alle 6 datasett: byggimport, NVDB-mangler, highway-tag, SSR, N50, barnehagefakta). Alle kall returnerer 200 og kommunene blir fargelagt korrekt på kartet.Test plan
osmno.github.io/progress-visualizer/.Failed to fetch/ERR_CONTENT_DECODING_FAILEDi console.