stephenou / fruitionsite

Build your website with Notion for free
https://fruitionsite.com
MIT License
1.58k stars 216 forks source link

MermaidJS doesn't work on WebWorker #218

Open sanchezcarlosjr opened 1 year ago

sanchezcarlosjr commented 1 year ago

Web Issue

Issue:

Unknown error: ChunkLoadError: Loading chunk 5552 failed.
(missing: https://carlos-eduardo-sanchez-torres.sanchezcarlosjr.com/mermaid-c159349a3a44e74a0ca6.js)

Issue: image

The file loads: https://carlos-eduardo-sanchez-torres.sanchezcarlosjr.com/mermaid-c159349a3a44e74a0ca6.js

We use the Fruition latest version.

dphuang2 commented 1 year ago

noticed this too—any luck on fixing this?

nobel6018 commented 1 year ago

Any progress? errors for me too.

roger-twan commented 1 year ago

I encountered the same issue and has been fixed. Replace the code below in worker.js

if (url.pathname.startsWith("/app") && url.pathname.endsWith("js")) {
    response = await fetch(url.toString());
    let body = await response.text();
    response = new Response(
      body
        .replace(/www.notion.so/g, MY_DOMAIN)
        .replace(/notion.so/g, MY_DOMAIN),
      response
    );
    response.headers.set("Content-Type", "application/x-javascript");
    return response;

=>

if (url.pathname.endsWith('js')) {
      response = await fetch(url.toString());
      let body = await response.text();
      if (url.pathname.startsWith('/app')) {
        body = body.replace(/www.notion.so/g, MY_DOMAIN).replace(/notion.so/g, MY_DOMAIN);
      }
      response = new Response(body, response);
      response.headers.set('Content-Type', 'application/x-javascript');
      return response;

Hope this helps~

sanchezcarlosjr commented 1 year ago

It works. Thank you!