Fruition - Build Your Next Website With Notion, For Free

Furition uses Cloudfare.com and its worker script to make custom domain possible on Notion.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9237a680-d437-4d80-9328-2b9eb0d6eb84/Untitled.png

The worker script will rewrite the response to custom settings. For example, you can add a custom pagetitle, metadata and other pretty links. The script rewrite HTML head and page links in the HTML body to your settings from notion.so to your domain.

However, the provided script can make a page crash, because it rewrite ALL response, including API responses. For example, if you have a string <title> in the page(No matter in block, properties, comment...), you will not able to load the page, because the script accidentally modify the API response to which notion cannot parse.

Even worse, if you use Fruition and allow public comment in your page. Anyone can simply leave a comment <title>. Your page will have an error under your domain(but still accessible on notion.so).


Example

Original content on notion.so

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/694406e1-0059-4be3-8cfd-a6a567382acb/Untitled.png

Under custom domain.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/0d8a26f2-fa95-4645-a958-0fb87bfde51e/Untitled.png

The Fruition script rewrite the API response and make the page crashed.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c2602aee-6e5a-4de0-9150-425b19edea7d/Untitled.png

Error log.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4dcedfc2-9104-493c-8e4b-bb86aac67e38/Untitled.png

Worker script

Rewriter

element.setInnerContent(PAGE_TITLE); is expected to rewrite page title.

class MetaRewriter {
  element(element) {
    if (PAGE_TITLE !== '') {
      if (element.getAttribute('property') === 'og:title'
        || element.getAttribute('name') === 'twitter:title') {
        element.setAttribute('content', PAGE_TITLE);
      }
      if (element.tagName === 'title') {
        element.setInnerContent(PAGE_TITLE);
      }
    }
    if (PAGE_DESCRIPTION !== '') {
      if (element.getAttribute('name') === 'description'
        || element.getAttribute('property') === 'og:description'
        || element.getAttribute('name') === 'twitter:description') {
        element.setAttribute('content', PAGE_DESCRIPTION);
      }
    }
    if (element.getAttribute('property') === 'og:url'
      || element.getAttribute('name') === 'twitter:url') {
      element.setAttribute('content', MY_DOMAIN);
    }
    if (element.getAttribute('name') === 'apple-itunes-app') {
      element.remove();
    }
  }
}