Fruition - Build Your Next Website With Notion, For Free
Furition uses Cloudfare.com and its worker script to make custom domain possible on Notion.
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
).
Original content on notion.so
Under custom domain.
The Fruition script rewrite the API response and make the page crashed.
Error log.
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();
}
}
}