From b8acd446600cc0d3693f1a7303a3608c39b81890 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Thu, 6 Aug 2026 18:48:47 +1000 Subject: [PATCH] Use CORS-clean hosts for in-browser data reads 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///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 --- lectures/inequality.md | 2 +- lectures/inflation_history.md | 4 ++-- lectures/long_run_growth.md | 2 +- lectures/mle.md | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lectures/inequality.md b/lectures/inequality.md index 767891d..d2a6719 100644 --- a/lectures/inequality.md +++ b/lectures/inequality.md @@ -247,7 +247,7 @@ The following code block imports a subset of the dataset `SCF_plus` for 2016, which is derived from the [Survey of Consumer Finances](https://en.wikipedia.org/wiki/Survey_of_Consumer_Finances) (SCF). ```{code-cell} ipython3 -url = 'https://github.com/QuantEcon/high_dim_data/raw/main/SCF_plus/SCF_plus_mini.csv' +url = 'https://media.githubusercontent.com/media/QuantEcon/high_dim_data/main/SCF_plus/SCF_plus_mini.csv' df = pd.read_csv(url) df_income_wealth = df.dropna() ``` diff --git a/lectures/inflation_history.md b/lectures/inflation_history.md index dda01f4..8fa05f9 100644 --- a/lectures/inflation_history.md +++ b/lectures/inflation_history.md @@ -73,7 +73,7 @@ Let us bring the data into pandas from a spreadsheet that is [hosted on GitHub]( ```{code-cell} ipython3 # Import data and clean up the index pyodide_http.patch_all() -data_url = "https://github.com/QuantEcon/data-lectures/raw/main/lectures/longprices.xls" +data_url = "https://raw.githubusercontent.com/QuantEcon/data-lectures/main/lectures/longprices.xls" df_fig5 = pd.read_excel(data_url, sheet_name='all', header=2, @@ -347,7 +347,7 @@ We prepare the data for each country ```{code-cell} ipython3 # Import data -data_url = "https://github.com/QuantEcon/data-lectures/raw/main/lectures/chapter_3.xlsx" +data_url = "https://raw.githubusercontent.com/QuantEcon/data-lectures/main/lectures/chapter_3.xlsx" xls = pd.ExcelFile(data_url) # Select relevant sheets diff --git a/lectures/long_run_growth.md b/lectures/long_run_growth.md index 854400c..21aaa7a 100644 --- a/lectures/long_run_growth.md +++ b/lectures/long_run_growth.md @@ -94,7 +94,7 @@ Here we read the Maddison data into a pandas `DataFrame`: ```{code-cell} ipython3 pyodide_http.patch_all() -data_url = "https://github.com/QuantEcon/data-lectures/raw/main/lectures/mpd2020.xlsx" +data_url = "https://raw.githubusercontent.com/QuantEcon/data-lectures/main/lectures/mpd2020.xlsx" data = pd.read_excel(data_url, sheet_name='Full data') data.head() diff --git a/lectures/mle.md b/lectures/mle.md index a21e222..d2de7b2 100644 --- a/lectures/mle.md +++ b/lectures/mle.md @@ -92,7 +92,7 @@ The following code imports this data and reads it into an array called `sample` ```{code-cell} ipython3 :tags: [hide-input] -url = 'https://github.com/QuantEcon/high_dim_data/raw/main/SCF_plus/SCF_plus_mini_no_weights.csv' +url = 'https://media.githubusercontent.com/media/QuantEcon/high_dim_data/main/SCF_plus/SCF_plus_mini_no_weights.csv' df = pd.read_csv(url) df = df.dropna() df = df[df['year'] == 2016]