🏠 back to Observable

Connecting to API through CORS

I have multiple people using the same notebook to generate charts. The notebook fetch the data from API and most users don’t meet any problem accessing the data and see the chart. However, only one user kept telling me she cannot access the data and sent me this screenshot:

Her browser is Chrome and she access the notebook using the incognito mode.

Link to the notebook: Crypto Asset Volatility (30d) / CoinDesk / Observable

1 Like

It’s possible that they’re hitting the glitch.com rate limit for free instances. I’d suggest to set up your own CORS proxy. You can fork the glitch project here: Glitch


You can also use CORS Proxy fetchp / Tom Larkworthy / Observable

which you can lock down to a single upstream domain.

import {fetchp} with {DOMAINS as ALLOW_DOMAINS} from '@tomlarkworthy/fetchp'
DOMAINS = ['fred.stlouisfed.org']

You use fetchp like normal fetch. It’s a bit slow to startup though, the glitch one is faster. fetchp can also inject secrets, so then it becomes quite useful as an API proxy.