diff --git a/worker.js b/worker.js index 248f1d5..65a6c91 100644 --- a/worker.js +++ b/worker.js @@ -3,8 +3,13 @@ /* Step 1: enter your domain name like fruitionsite.com */ const MY_DOMAIN = "fruitionsite.com"; +/* Step 2: enter workspace 'domain' value on notion.so + * > settings & members > settings > domain + */ +const SPACE_DOMAIN = 'stephenou'; + /* - * Step 2: enter your URL slug to page ID mapping + * Step 3: enter your URL slug to page ID mapping * The key on the left is the slug (without the slash) * The value on the right is the Notion page ID */ @@ -15,15 +20,15 @@ const SLUG_TO_PAGE = { roadmap: "7d4b21bfb4534364972e8bf9f68c2c36" }; -/* Step 3: enter your page title and description for SEO purposes */ +/* Step 4: enter your page title and description for SEO purposes */ const PAGE_TITLE = "Fruition"; const PAGE_DESCRIPTION = "Free, Open Source Toolkit For Customizing Your Notion Page"; -/* Step 4: enter a Google Font name, you can choose from https://fonts.google.com */ +/* Step 5: enter a Google Font name, you can choose from https://fonts.google.com */ const GOOGLE_FONT = "Rubik"; -/* Step 5: enter any custom scripts you'd like */ +/* Step 6: enter any custom scripts you'd like */ const CUSTOM_SCRIPT = ``; /* CONFIGURATION ENDS HERE */ @@ -115,7 +120,17 @@ async function fetchAndApply(request) { }, method: "POST" }); - response = new Response(response.body, response); + + let body = await response.text() + const data = JSON.parse(body); + + if (url.pathname.includes("getPublicPageData")) { + if(data.spaceDomain!=SPACE_DOMAIN){ + throw new Error('Not found on this notion account!') + } + } + + response = new Response(body, response); response.headers.set("Access-Control-Allow-Origin", "*"); } else if (slugs.indexOf(url.pathname.slice(1)) > -1) { const pageId = SLUG_TO_PAGE[url.pathname.slice(1)];