- Made with and hosted by Notion
- Cloudflare nameserver set up with a Squarespace domain
- Cloudflare worker performs a redirect to clean up Notion URL
- This video shows how to set up the Cloudflare worker and nameserver but I use my own script:
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request));
});
async function fetchAndApply(request) {
const url = new URL(request.url)
// Modify the URL to point to the Notion page
url.hostname = 'well-pudding-eb5.notion.site'
url.pathname = '/Wanna-hear-a-fun-fact-140606aaa9a742cc9ce9d070136cf5d5'
// Fetch the Notion page content
let response = await fetch(url.toString(), {
method: request.method,
headers: request.headers,
body: request.method === 'POST' ? request.body : undefined,
redirect: 'follow'
})
// Modify the response to make sure it works well with your domain
response = new Response(response.body, response)
response.headers.set('Access-Control-Allow-Origin', '*')
response.headers.delete('Content-Security-Policy')
response.headers.delete('X-Content-Security-Policy')
return response
}