Use CORS-clean hosts for in-browser data reads - #54
Merged
Merged
Conversation
This site executes code cells in the reader's browser (Pyodide via pyodide_http), so every pandas URL read is subject to CORS on each redirect hop. The github.com/<org>/<repo>/raw/ form 302s with an empty access-control-allow-origin header and fails in the browser before the redirect is followed; raw.githubusercontent.com and (for LFS files) media.githubusercontent.com serve access-control-allow-origin: * and work. Flips the five affected reads: - long_run_growth.md, inflation_history.md: the data-lectures reads repointed in #52/#53 move to raw.githubusercontent.com - inequality.md, mle.md: the pre-existing SCF reads move to media.githubusercontent.com (the LFS host heavy_tails already uses) {download} links and prose links are plain navigations, so they keep the github.com form. All five new URLs verified fetching from this site's origin in headless Chromium with the exact expected byte counts. The regression and the repoint rule are tracked in QuantEcon/data-lectures#46. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
❌ Deploy Preview for beautiful-dodol-cb9543 failed.
|
There was a problem hiding this comment.
Pull request overview
Updates a handful of in-lecture, in-browser (Pyodide) pandas data reads to use CORS-friendly GitHub content hosts so fetches succeed under browser CORS rules (especially across redirects).
Changes:
- Switched data reads in
long_run_growthandinflation_historyfromgithub.com/<org>/<repo>/raw/...toraw.githubusercontent.com/...to avoid redirect/CORS failures. - Switched LFS-backed CSV reads in
inequalityandmlefromgithub.com/<org>/<repo>/raw/...tomedia.githubusercontent.com/...to ensure the browser receives file bytes (not a blocked redirect or LFS pointer path).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lectures/mle.md | Repoints SCF CSV read to media.githubusercontent.com for CORS-clean in-browser fetch. |
| lectures/long_run_growth.md | Repoints Maddison XLSX read to raw.githubusercontent.com to avoid CORS/redirect issues. |
| lectures/inflation_history.md | Repoints two Excel reads to raw.githubusercontent.com to keep browser fetches CORS-clean. |
| lectures/inequality.md | Repoints SCF CSV read to media.githubusercontent.com for CORS-clean in-browser fetch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Aug 6, 2026
|
📖 Netlify Preview Ready! Preview URL: https://pr-54--beautiful-dodol-cb9543.netlify.app (b8acd44) ✨ Browse the preview at the URL above. |
38 tasks
mmcky
added a commit
to QuantEcon/data-lectures
that referenced
this pull request
Aug 6, 2026
lecture-wasm executes cells in the reader's browser, where CORS applies to every redirect hop; the github.com/*/raw/ form 302s with an empty access-control-allow-origin header and fails there, while raw.githubusercontent.com and media.githubusercontent.com (LFS) serve ACAO * and work. The set 1/2 wasm repoints normalised wasm URLs to the one form its runtime cannot fetch — found by the #45 validation, tracked in #46, fixed in QuantEcon/lecture-wasm#54. Also records the Phase 4 consequence: data.quantecon.org must serve ACAO * before lecture-wasm can cut over (#37). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 6, 2026
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.
This site executes code cells in the reader's browser (Pyodide via
pyodide_http.patch_all()), so every pandas URL read is subject to CORS on each redirect hop. Thegithub.com/<org>/<repo>/raw/…form is a 302 whose response carries an emptyaccess-control-allow-originheader, which browsers reject before following the redirect — so those reads fail in the one repo where the browser is the runtime.raw.githubusercontent.comand (for LFS files)media.githubusercontent.comserveaccess-control-allow-origin: *and work. The regression and the accompanying repoint rule are tracked in QuantEcon/data-lectures#46.Five reads flipped, two groups:
long_run_growthmpd2020.xlsxgithub.com/QuantEcon/data-lectures/raw/…(from #52)raw.githubusercontent.cominflation_historylongprices.xls,chapter_3.xlsxgithub.com/QuantEcon/data-lectures/raw/…(from #53)raw.githubusercontent.cominequalitySCF_plus_mini.csvgithub.com/QuantEcon/high_dim_data/raw/…(pre-existing)media.githubusercontent.com(LFS)mleSCF_plus_mini_no_weights.csvgithub.com/QuantEcon/high_dim_data/raw/…(pre-existing)media.githubusercontent.com(LFS)The
{download}link and prose links keep thegithub.comform — they are plain navigations, CORS does not apply, and that form gives the reader the friendlier GitHub UI on click.Verification: all five new URLs fetched from this site's own origin (
quantecon.github.io) in headless Chromium — 200 with the exact expected sizes (1,765,204 / 388,608 / 73,281 / 32,853,734 / 75,902,999 bytes; the first three byte-identical to the sha256-verified data-lectures copies). The old form fails the same test withFailed to fetch. Reproduce from anyquantecon.github.iopage console:fetch('https://github.com/QuantEcon/data-lectures/raw/main/lectures/mpd2020.xlsx')rejects; theraw.githubusercontent.comequivalent resolves.The data-lectures audit classifies references by org/repo across all GitHub URL forms, so these stay pattern
data-lectures/unchanged — the strict migration-consistency check is unaffected.🤖 Generated with Claude Code