Implementing a CORS proxy using Cloudflare Workers to overcome the limitations of the Notion API, which does not allow cross-origin requests by default.
See issue here: makenotion/notion-sdk-js#96
This worker is deployed on Cloudflare.
Steps to set this up:
- Create a Cloudflare account at https://dash.cloudflare.com/
- Under Workers tab, click on
Create a Service
- Name the service, and click
Create Service
-
Click on
Quick Edit
-
Paste the
index.js
file into the code editor (modified from https://developers.cloudflare.com/workers/examples/cors-header-proxy/) -
Click Deploy!
Now any requests made to https://demo.zinean00.workers.dev/cors/<url>
will forward the requests to <url>
while adding the "Access-Control-Allow-Origin: *" in the reply header.
This then allows us to make requests to Notion API through a browser!