stephenou / fruitionsite

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

All fruition website down #107

Open leoleung25 opened 3 years ago

leoleung25 commented 3 years ago

I have my website hosted with the fruition script and it just went down showing "Mismatch between origin and baseURL (Dev)." Even the fruition website and most of the showcase websites are down. Please fix. Thanks

willzhaoworld commented 3 years ago

same issue as above

tamagamis commented 3 years ago

If it is correct and I do not see any post or something referring to the creator: C I do not want to know what the end is xd

here I see a post on reddit https://www.reddit.com/r/Notion/comments/p3wgyn/is_it_just_happening_to_me_fruitionsitecom/

bejaeger commented 3 years ago

Same problem here, any information about how and when this can be fixed would be super appreciated!

mohasxd commented 3 years ago

I have the same problem. Unfortunately things have been looing troubling for fruitionsite since Notion decided to add their own "custom" URLs. I hope there is a solution!!!!

wentin commented 3 years ago

Thanks to Ryo from Notion, my site is working now:

https://startup.wentin.net/

This is how to fix it

my old code on Cloudflare:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

my new code:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      window.CONFIG.domainBaseUrl = "https://startup.wentin.net";
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

the line I added that fixed the issue

  window.CONFIG.domainBaseUrl = "https://startup.wentin.net";
laughnan commented 3 years ago

Your (and Ryo's) fix worked for me, @wentin! I changed the configuration slightly to pull from MY_DOMAIN but I have a pull request up for @stephenou: https://github.com/stephenou/fruitionsite/pull/109

jruers commented 3 years ago

works fine for all old sites created in Notion ! 馃憤馃徎 But when I create a new site with the new Notion domain it always shows: ERR_TOO_MANY_REDIRECTS after uploading the worker code. Any suggestions what is going wrong ?

laughnan commented 3 years ago

@jruers what is the new site URL that you're trying? When testing my PR code I used a brand new share URL and the latest worker.js code.

jruers commented 3 years ago

@laughnan www.enfim.eu

laughnan commented 3 years ago

And what's the Notion URL that you're using @jruers ?

tamagamis commented 3 years ago

@laughnan www.enfim.eu

yes i see

_check your dns or domain address if there are no changes, it happened to me but the solution for me was to purge cache and how I have implemented it with cloudflare delete and create new workers_

and I also recommend that you regenerate the code after debugging and deleting workers so that everything is clean and as new and wait for it to be distributed
jruers commented 3 years ago

@laughnan https://enfim.notion.site/eb6e671f1df340a0a3bd1362df05033b

@Creadors thx. I have tried that already, but we'll give it another try

tamagamis commented 3 years ago

@laughnan https://enfim.notion.site/eb6e671f1df340a0a3bd1362df05033b

@Creadors gracias. Ya lo he intentado, pero lo intentaremos de nuevo.

Okay, the problem is already with the domain or place where you have it hosted. It still checks in workers that it is redirecting to the domain that you have 'enfim.eu'; / from worker without the www. for something like that enfim.eu/ or .enfim.eu

jruers commented 3 years ago

@Creadors checked all configurations at the provider. but are all the same like e.g. enfim.nl I only have these problems with new notion sites after they changed the domain setup. bcoolr.com or casa-m.es same not working. but old like enfim.nl working fine.

disachantel commented 3 years ago

Thanks to Ryo from Notion, my site is working now:

https://startup.wentin.net/

This is how to fix it

my old code on Cloudflare:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

my new code:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      window.CONFIG.domainBaseUrl = "https://startup.wentin.net";
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

the line I added that fixed the issue

  window.CONFIG.domainBaseUrl = "https://startup.wentin.net";

thank you for sharing! this fixed my problem.

bungspaces commented 3 years ago

Thanks to Ryo from Notion, my site is working now:

https://startup.wentin.net/

This is how to fix it

my old code on Cloudflare:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

my new code:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      window.CONFIG.domainBaseUrl = "https://startup.wentin.net";
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

the line I added that fixed the issue

  window.CONFIG.domainBaseUrl = "https://startup.wentin.net";

how to found this code? what file should i open?

tamagamis commented 3 years ago

Gracias a Ryo de Notion, mi sitio est谩 funcionando ahora: https://startup.wentin.net/ As铆 es como solucionarlo mi antiguo c贸digo en Cloudflare:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

mi nuevo c贸digo:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      window.CONFIG.domainBaseUrl = "https://startup.wentin.net";
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

la l铆nea que agregu茅 que solucion贸 el problema

  window.CONFIG.domainBaseUrl = "https://startup.wentin.net";

驴c贸mo encontrar este c贸digo? 驴Qu茅 archivo debo abrir?

https://github.com/stephenou/fruitionsite/blob/master/worker.js

ozanozyegen commented 3 years ago

Tried the recommended solutions window.CONFIG.domainBaseUrl = "https://startup.wentin.net"; and @Creadors advice of purging and recreating the workers.

I am still getting the same error. "Mismatch between origin and baseURL (Dev)."

Route is ozyegen.com/* (also tried *ozyegen.com/*).

Worker code `/* CONFIGURATION STARTS HERE */ /* Step 1: enter your domain name like fruitionsite.com */ const MY_DOMAIN = 'ozyegen.com'; /* * Step 2: 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 */ const SLUG_TO_PAGE = { '': '7d789df7219840e3a575ba6ed212b228', 'welcome': '7d789df7219840e3a575ba6ed212b228', 'about': '1cfafdeeab064b10b1f308edc02c7d1d', 'contact': '52c81731cd81400cbaf619b92df8d2d0', 'blog': 'd43b07d3578f40c8bf708ee588948399', }; /* Step 3: enter your page title and description for SEO purposes */ const PAGE_TITLE = 'Ozan Ozyegen'; const PAGE_DESCRIPTION = 'Ozan Ozyegen\'s Website '; /* Step 4: enter a Google Font name, you can choose from https://fonts.google.com */ const GOOGLE_FONT = ''; /* Step 5: enter any custom scripts you'd like */ const CUSTOM_SCRIPT = ` `; /* CONFIGURATION ENDS HERE */ const PAGE_TO_SLUG = {}; const slugs = []; const pages = []; Object.keys(SLUG_TO_PAGE).forEach(slug => { const page = SLUG_TO_PAGE[slug]; slugs.push(slug); pages.push(page); PAGE_TO_SLUG[page] = slug; }); addEventListener('fetch', event => { event.respondWith(fetchAndApply(event.request)); }); function generateSitemap() { let sitemap = ''; slugs.forEach( (slug) => (sitemap += 'https://' + MY_DOMAIN + '/' + slug + '') ); sitemap += ''; return sitemap; } const corsHeaders = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, HEAD, POST, PUT, OPTIONS', 'Access-Control-Allow-Headers': 'Content-Type', }; function handleOptions(request) { if (request.headers.get('Origin') !== null && request.headers.get('Access-Control-Request-Method') !== null && request.headers.get('Access-Control-Request-Headers') !== null) { // Handle CORS pre-flight request. return new Response(null, { headers: corsHeaders }); } else { // Handle standard OPTIONS request. return new Response(null, { headers: { 'Allow': 'GET, HEAD, POST, PUT, OPTIONS', } }); } } async function fetchAndApply(request) { if (request.method === 'OPTIONS') { return handleOptions(request); } let url = new URL(request.url); url.hostname = 'www.notion.so'; if (url.pathname === '/robots.txt') { return new Response('Sitemap: https://' + MY_DOMAIN + '/sitemap.xml'); } if (url.pathname === '/sitemap.xml') { let response = new Response(generateSitemap()); response.headers.set('content-type', 'application/xml'); return response; } let fullPathname = request.url.replace("https://" + MY_DOMAIN, ""); let response; 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; } else if ((url.pathname.startsWith('/api'))) { // Forward API response = await fetch(url.toString(), { body: request.body, headers: { 'content-type': 'application/json;charset=UTF-8', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36' }, method: 'POST', }); response = new Response(response.body, response); response.headers.set('Access-Control-Allow-Origin', '*'); return response; } else if (slugs.indexOf(url.pathname.slice(1)) > -1) { const pageId = SLUG_TO_PAGE[url.pathname.slice(1)]; return Response.redirect('https://' + MY_DOMAIN + '/' + pageId, 301); } else { response = await fetch(url.toString(), { body: request.body, headers: request.headers, method: request.method, }); response = new Response(response.body, response); response.headers.delete('Content-Security-Policy'); response.headers.delete('X-Content-Security-Policy'); } return appendJavascript(response, SLUG_TO_PAGE); } 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(); } } } class HeadRewriter { element(element) { if (GOOGLE_FONT !== '') { element.append(` `, { html: true }); } element.append(``, { html: true }) } } class BodyRewriter { constructor(SLUG_TO_PAGE) { this.SLUG_TO_PAGE = SLUG_TO_PAGE; } element(element) { element.append(`
Powered by Fruition
${CUSTOM_SCRIPT}`, { html: true }); } } async function appendJavascript(res, SLUG_TO_PAGE) { return new HTMLRewriter() .on('title', new MetaRewriter()) .on('meta', new MetaRewriter()) .on('head', new HeadRewriter()) .on('body', new BodyRewriter(SLUG_TO_PAGE)) .transform(res); } `
laughnan commented 3 years ago

@ozanozyegen you want it to be your custom domain, see this as a sample: https://github.com/stephenou/fruitionsite/pull/109

tamagamis commented 3 years ago

Prob茅 las soluciones recomendadas window.CONFIG.domainBaseUrl = "https://startup.wentin.net"; y los consejos de @Creadors de purgar y recrear a los trabajadores.

Sigo recibiendo el mismo error. "Mismatch between origin and baseURL (Dev)."

La ruta es ozyegen.com/*(tambi茅n probada *ozyegen.com/*).

C贸digo de trabajador

Greetings, if I see that you still get the error. try the direct corrections of the base code and then customize it so that you do not have any errors.

Code Active: https://fruition-git-master-stephenou.vercel.app/ generate new code

ozanozyegen commented 3 years ago

@ozanozyegen you want it to be your custom domain, see this as a sample: #109

Thank you, problem solved.

jjamesss1 commented 3 years ago

Hi, there!!

Thank you all for this quick response once the change on Notion was implemented. EXTREMELY helpful for a non-coder as me :). I faced another issue, dDoes anyone knows how to solve this one?

"Continue to external site by following the link below"

https://pasteboard.co/KfRjfeV.jpg

Edit: created issue #116 for this.

hhimanshu commented 3 years ago

I still get an error. The steps I followed are below

  1. Deleted worker and re-created one
  2. Re-created script using the latest link. Saved and deployed
  3. Added route for *harit.dev/* and link the newly created worker

When I hit my website , I see blank page with following error on Developer Console. Have I missed something? Thanks

9e069ff6c2ad42c5ad04aad8a3c4276c:1 GET https://harit.dev/9e069ff6c2ad42c5ad04aad8a3c4276c 404
396-a6d8ddb95dcbfea07e7b.js:1 2021-08-18T16:41:07.062Z [info] FeatureFlagTransactionQueue preferIndexedDB {}
app-dff7cb8e1a5ee8eaf52b.js:1 GET https://analytics.pgncs.harit.dev/analytics.js/v1/g1mMn2qquRcv7exBIVDivoKl9cOrdxLA/analytics.min.js net::ERR_NAME_NOT_RESOLVED
t.load @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
ee @ app-dff7cb8e1a5ee8eaf52b.js:1
Q @ app-dff7cb8e1a5ee8eaf52b.js:1
willMount @ app-dff7cb8e1a5ee8eaf52b.js:1
UNSAFE_componentWillMount @ app-dff7cb8e1a5ee8eaf52b.js:1
Za @ 396-a6d8ddb95dcbfea07e7b.js:1
lo @ 396-a6d8ddb95dcbfea07e7b.js:1
Ps @ 396-a6d8ddb95dcbfea07e7b.js:1
xs @ 396-a6d8ddb95dcbfea07e7b.js:1
ks @ 396-a6d8ddb95dcbfea07e7b.js:1
ms @ 396-a6d8ddb95dcbfea07e7b.js:1
Ks @ 396-a6d8ddb95dcbfea07e7b.js:1
Js @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
Ds @ 396-a6d8ddb95dcbfea07e7b.js:1
au @ 396-a6d8ddb95dcbfea07e7b.js:1
render @ 396-a6d8ddb95dcbfea07e7b.js:1
O @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
async function (async)
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
68530 @ app-dff7cb8e1a5ee8eaf52b.js:1
d @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
d.O @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
396-a6d8ddb95dcbfea07e7b.js:1 POST https://harit.dev/api/v3/getPublicPageData 500
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
c @ app-dff7cb8e1a5ee8eaf52b.js:1
Z @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
M @ app-dff7cb8e1a5ee8eaf52b.js:1
396-a6d8ddb95dcbfea07e7b.js:1 HttpRequestError: Something went wrong.
    at c (app-dff7cb8e1a5ee8eaf52b.js:1)
    at async Z (app-dff7cb8e1a5ee8eaf52b.js:1)
    at async Object.M (app-dff7cb8e1a5ee8eaf52b.js:1)
    at async Promise.all (index 0)
    at async Object.F (app-dff7cb8e1a5ee8eaf52b.js:1)
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
Z @ app-dff7cb8e1a5ee8eaf52b.js:1
async function (async)
Z @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
M @ app-dff7cb8e1a5ee8eaf52b.js:1
396-a6d8ddb95dcbfea07e7b.js:1 2021-08-18T16:41:07.257Z [error] main ClientError {error: {鈥}
app-dff7cb8e1a5ee8eaf52b.js:1 Uncaught (in promise) HttpRequestError: Something went wrong.
    at c (app-dff7cb8e1a5ee8eaf52b.js:1)
    at async Z (app-dff7cb8e1a5ee8eaf52b.js:1)
    at async Object.M (app-dff7cb8e1a5ee8eaf52b.js:1)
    at async Promise.all (index 0)
    at async Object.F (app-dff7cb8e1a5ee8eaf52b.js:1)
d @ app-dff7cb8e1a5ee8eaf52b.js:1
c @ app-dff7cb8e1a5ee8eaf52b.js:1
async function (async)
F @ app-dff7cb8e1a5ee8eaf52b.js:1
_t @ app-dff7cb8e1a5ee8eaf52b.js:1
async function (async)
_t @ app-dff7cb8e1a5ee8eaf52b.js:1
Zt @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
async function (async)
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
68530 @ app-dff7cb8e1a5ee8eaf52b.js:1
d @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
d.O @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
(anonymous) @ app-dff7cb8e1a5ee8eaf52b.js:1
396-a6d8ddb95dcbfea07e7b.js:1 POST https://o324374.ingest.sentry.io/api/5741876/store/?sentry_key=704fe3b1898d4ccda1d05fe1ee79a1f7&sentry_version=7 403
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
e @ 396-a6d8ddb95dcbfea07e7b.js:1
t.sendEvent @ 396-a6d8ddb95dcbfea07e7b.js:1
e.sendEvent @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
onfulfilled @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
_executeHandlers @ 396-a6d8ddb95dcbfea07e7b.js:1
_attachHandler @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
e @ 396-a6d8ddb95dcbfea07e7b.js:1
e.then @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
e @ 396-a6d8ddb95dcbfea07e7b.js:1
e._processEvent @ 396-a6d8ddb95dcbfea07e7b.js:1
e.captureEvent @ 396-a6d8ddb95dcbfea07e7b.js:1
e._invokeClient @ 396-a6d8ddb95dcbfea07e7b.js:1
e.captureEvent @ 396-a6d8ddb95dcbfea07e7b.js:1
callback @ 396-a6d8ddb95dcbfea07e7b.js:1
$e @ 396-a6d8ddb95dcbfea07e7b.js:1
Ye.Se.onunhandledrejection @ 396-a6d8ddb95dcbfea07e7b.js:1
396-a6d8ddb95dcbfea07e7b.js:1 POST https://o324374.ingest.sentry.io/api/5741876/store/?sentry_key=704fe3b1898d4ccda1d05fe1ee79a1f7&sentry_version=7 403
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
e @ 396-a6d8ddb95dcbfea07e7b.js:1
t.sendEvent @ 396-a6d8ddb95dcbfea07e7b.js:1
e.sendEvent @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
onfulfilled @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
_executeHandlers @ 396-a6d8ddb95dcbfea07e7b.js:1
_attachHandler @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
e @ 396-a6d8ddb95dcbfea07e7b.js:1
e.then @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
e @ 396-a6d8ddb95dcbfea07e7b.js:1
e._processEvent @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
onfulfilled @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
_executeHandlers @ 396-a6d8ddb95dcbfea07e7b.js:1
_attachHandler @ 396-a6d8ddb95dcbfea07e7b.js:1
(anonymous) @ 396-a6d8ddb95dcbfea07e7b.js:1
e @ 396-a6d8ddb95dcbfea07e7b.js:1
e.then @ 396-a6d8ddb95dcbfea07e7b.js:1
e.captureException @ 396-a6d8ddb95dcbfea07e7b.js:1
e._invokeClient @ 396-a6d8ddb95dcbfea07e7b.js:1
e.captureException @ 396-a6d8ddb95dcbfea07e7b.js:1
o @ 396-a6d8ddb95dcbfea07e7b.js:1
s @ 396-a6d8ddb95dcbfea07e7b.js:1
a @ app-dff7cb8e1a5ee8eaf52b.js:1
l @ app-dff7cb8e1a5ee8eaf52b.js:1
async function (async)
l @ app-dff7cb8e1a5ee8eaf52b.js:1
r @ 396-a6d8ddb95dcbfea07e7b.js:1
prodaea commented 3 years ago

Yeah see #113 , that's a bit different than this one.

Stonerkid commented 3 years ago

Hi! I still find the "Mismatch between origin and baseUrl (dev)." message. I've tried all the solutions here including the new code but they're not working, it's so frustrating :(

Any thoughts?

fastndcurious commented 3 years ago

Hi there,

Fixed & working well for me. The prob seems to come from the Fruition Code generation for the Cloudfare worker (step 3).

window.CONFIG.domainBaseUrl = "https://yourdomainname.com"; instead of window.CONFIG.domainBaseUrl = 'https://${MY_DOMAIN}'

By the way my JS is a bit rusty. What is exactly the difference between CONST = 'https://\${MY_DOMAIN}' CONST = 'https://${MY_DOMAIN}

@stephenou maybe could you update this PR https://github.com/stephenou/fruitionsite/commit/8b1f7dcf4e593348f3ba73a345f8b99b01dfc47d

Thanks,

Stonerkid commented 3 years ago

Sorry, I don't get it. Are you refering to the code at step 2? (the one with the "copy the code" button) Otherwise I don't understand what do you mean by step 3. Besides, I can't tell the difference between the new line you have written and the one given at Fruitonsite.

Stonerkid commented 3 years ago

According to the comments to this post [https://michaeljfordham.medium.com/how-and-why-im-using-notion-as-my-portfolio-c4eb927b613c], "It appears an update Notion rolled out last week has broken a lot of Fruition sites". Anyone else with the same problems? I have recently renewed my domain and other stuff and I'm afraid it's wasted money :( :( :(

tamagamis commented 3 years ago

I understand, currently my sites are operational.

Stonerkid commented 3 years ago

I understand, currently my sites are operational.

But did you have the same problem?

fastndcurious commented 3 years ago

Sorry, I don't get it. Are you refering to the code at step 2? (the one with the "copy the code" button) Otherwise I don't understand what do you mean by step 3. Besides, I can't tell the difference between the new line you have written and the one given at Fruitonsite.

Yes the Step 2 in Fruition when copying the code in the Worker into Cloudfare

tarkolar commented 3 years ago

Hi, I'm facing this issue since the beginning but no matter how much I tried, it still exists. I tried:

my website is onurolgun.com and notion link: https://forest-blob-004.notion.site/Merhaba-dd04482390504dfdbe8367ccb08a696f

Can anyone share any idea, please?

This code (new) does not work: ` const PAGE_TO_SLUG = {}; const slugs = []; const pages = []; Object.keys(SLUG_TO_PAGE).forEach(slug => { const page = SLUG_TO_PAGE[slug]; slugs.push(slug); pages.push(page); PAGE_TO_SLUG[page] = slug; });

addEventListener('fetch', event => { event.respondWith(fetchAndApply(event.request)); });

function generateSitemap() { let sitemap = ''; slugs.forEach( (slug) => (sitemap += 'https://' + MY_DOMAIN + '/' + slug + '') ); sitemap += ''; return sitemap; }

const corsHeaders = { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, HEAD, POST, PUT, OPTIONS', 'Access-Control-Allow-Headers': 'Content-Type', };

function handleOptions(request) { if (request.headers.get('Origin') !== null && request.headers.get('Access-Control-Request-Method') !== null && request.headers.get('Access-Control-Request-Headers') !== null) { // Handle CORS pre-flight request. return new Response(null, { headers: corsHeaders }); } else { // Handle standard OPTIONS request. return new Response(null, { headers: { 'Allow': 'GET, HEAD, POST, PUT, OPTIONS', } }); } }

async function fetchAndApply(request) { if (request.method === 'OPTIONS') { return handleOptions(request); } let url = new URL(request.url); url.hostname = 'www.notion.so'; if (url.pathname === '/robots.txt') { return new Response('Sitemap: https://' + MY_DOMAIN + '/sitemap.xml'); } if (url.pathname === '/sitemap.xml') { let response = new Response(generateSitemap()); response.headers.set('content-type', 'application/xml'); return response; } let response; 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; } else if ((url.pathname.startsWith('/api'))) { // Forward API response = await fetch(url.toString(), { body: url.pathname.startsWith('/api/v3/getPublicPageData') ? null : request.body, headers: { 'content-type': 'application/json;charset=UTF-8', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36' }, method: 'POST', }); response = new Response(response.body, response); response.headers.set('Access-Control-Allow-Origin', '*'); return response; } else if (slugs.indexOf(url.pathname.slice(1)) > -1) { const pageId = SLUG_TO_PAGE[url.pathname.slice(1)]; return Response.redirect('https://' + MY_DOMAIN + '/' + pageId, 301); } else { response = await fetch(url.toString(), { body: request.body, headers: request.headers, method: request.method, }); response = new Response(response.body, response); response.headers.delete('Content-Security-Policy'); response.headers.delete('X-Content-Security-Policy'); }

return appendJavascript(response, SLUG_TO_PAGE);

}

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(); } } }

class HeadRewriter { element(element) { if (GOOGLE_FONT !== '') { element.append(`

`, { html: true }); } element.append(``, { html: true }) } } class BodyRewriter { constructor(SLUG_TO_PAGE) { this.SLUG_TO_PAGE = SLUG_TO_PAGE; } element(element) { element.append(`
Powered by Fruition
${CUSTOM_SCRIPT}`, { html: true }); } } async function appendJavascript(res, SLUG_TO_PAGE) { return new HTMLRewriter() .on('title', new MetaRewriter()) .on('meta', new MetaRewriter()) .on('head', new HeadRewriter()) .on('body', new BodyRewriter(SLUG_TO_PAGE)) .transform(res); }`
tamagamis commented 3 years ago

onurolgun.com

I understand your situation, I just tested this code with my workers and they work, you just have to edit the code.

imagen: https://ibb.co/khxwqVv

CODE FIX: https://gist.github.com/isjair/7f3f243d229de2873eb612129216288e

tarkolar commented 3 years ago

I understand your situation, I just tested this code with my workers and they work, you just have to edit the code. CODE FIX: https://gist.github.com/isjair/7f3f243d229de2873eb612129216288e

Thanks for your help. However, even though I copied the exact same code but only changed the domain and slug, and it still does not work.

Can you tell me that is there something I should do else, or change something from my domain provider, godaddY?

tamagamis commented 3 years ago

Entiendo tu situaci贸n, acabo de probar este c贸digo con mis trabajadores y ellos funcionan, solo tienes que editar el c贸digo. CORRECCI脫N DE C脫DIGO: https://gist.github.com/isjair/7f3f243d229de2873eb612129216288e

Gracias por su ayuda. Sin embargo, a pesar de que copi茅 exactamente el mismo c贸digo, solo cambi茅 el dominio y la, y todav铆a no funciona.

驴Puedes decirme que hay algo que deber铆a hacer de otra manera, o cambiar algo de mi proveedor de dominio, godaddY?

If you verify your domain provider and that everything is fine since the error that I get is that you cannot access the same domain you have, now if you have it from cloudflare verify the dns and you have deleted the cache in development mode and Go into private mode in the browser and check if you have access, if you do not have access there is an error from the provider in some configuration.

Because if the domain will work, it will send you the page with a very common baseurl error, but since it is not, then it is assumed that it is from a provider to cloudflare or the other way around. Greetings

tarkolar commented 3 years ago

As far as I tried, I still get the same baseUrl error. It is frustrating actually. I tried with my different domain in a different service provider but still the same issue. I am trying with a new Cloudflare account. I will share the results 馃憤

tarkolar commented 3 years ago

I am trying with a new Cloudflare account. I will share the results 馃憤

Nope, new Cloudflare account also didn't work. I'm out of ideas it still does not work.

I know that worker starts. Because when I try to enter the site, it goes 404 but adds the Slug at the end of the URL. However, it does not work completely. I cannot understand it and I'm out of ideas. Please, I need further assistance 馃檹 @isjair

tamagamis commented 3 years ago

I am trying with a new Cloudflare account. I will share the results 馃憤

Nope, new Cloudflare account also didn't work. I'm out of ideas it still does not work.

I know that worker starts. Because when I try to enter the site, it goes 404 but adds the Slug at the end of the URL. However, it does not work completely. I cannot understand it and I'm out of ideas. Please, I need further assistance 馃檹 @isjair

I understand your situation and at the same time it is very strange, have you tried to generate new code? from this post?

https://www.reddit.com/r/Notion/comments/p495vu/fruitionsite_correction_active/?utm_medium=android_app&utm_source=share or https://fruition-git-fork-laughnan-override-domainbaseurl-stephenou.vercel.app/

copied as is in worker once I make it clear cache, development mode and wait and open in incognito mode, since it worked for me as I attached it previously is strange

tarkolar commented 3 years ago

Hi again, I still cannot make it work. I tried a new link again but it is still the same. Cleared the cache also. Do you know that do I need to any specific A or any other dns code for my Cloudflare account? Btw, much appreciated for your help, thanks @isjair

tamagamis commented 3 years ago

SmartSelect_20210902-072635_Chrome my dns configuration is not needed for more. so without www ai you do not have it configured at the time of registering the domain in cloudflare, the redirected to www will not let you place it. so try the domain without www.

Hola de nuevo, todav铆a no puedo hacer que funcione. Intent茅 un nuevo enlace de nuevo, pero sigue siendo el mismo. Tambi茅n borr贸 el cach茅. 驴Sabe que necesito alg煤n c贸digo A espec铆fico o cualquier otro c贸digo dns para mi cuenta de Cloudflare? Por cierto, muy apreciado por tu ayuda, gracias @isjair

lkayy commented 3 years ago

There seems to be reference to two different errors in this post. The "redirect" error that happened about a month ago and the more recent "Mismatch" error.

The "redirect" error was due to Notions update allowing users to set a public user name under account settings and if this was not completed by a certain date Notion would assign a temporary user name. If this has happened to you then you would have noticed a strange url on your public site.

To correct this you must first choose a public url for your workspace under your Notion settings. Then this must be updated in the cloudflare worker script ONLY if the change altered the plug. If it did not then the redirect should processed through cloudflare.

The "Mismatch" error can be corrected (as stated in a previous comment) by adding window.CONFIG.domainBaseUrl = "https://yourdomainname.com";

I have seen several posts on Reddit that this is to be added to line 4, however it depends on the script your are using. If you are using the original (or close to original) Fruition script, then the line will be added closer to the bottom (under "element. append"). Be sure to replace the "yourdomainname" with your custom domain. Save, deploy and exit worker.

I hope this helps

beatrixcendana commented 3 years ago

Thanks to Ryo from Notion, my site is working now: https://startup.wentin.net/ This is how to fix it my old code on Cloudflare:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

my new code:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      window.CONFIG.domainBaseUrl = "https://startup.wentin.net";
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

the line I added that fixed the issue

  window.CONFIG.domainBaseUrl = "https://startup.wentin.net";

how to found this code? what file should i open?

Click Worker - Manage Workers - Choose the workers that you made before - Quick Edit Check this link, read Create a script for Cloudflare Worker. They have more explanations of how to do it.

Stonerkid commented 3 years ago

Thanks to Ryo from Notion, my site is working now: https://startup.wentin.net/ This is how to fix it my old code on Cloudflare:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

my new code:

  class BodyRewriter {
    constructor(SLUG_TO_PAGE) {
      this.SLUG_TO_PAGE = SLUG_TO_PAGE;
    }
    element(element) {
      element.append(`<div style="display:none">Powered by <a href="http://fruitionsite.com">Fruition</a></div>
      <script>
      window.CONFIG.domainBaseUrl = "https://startup.wentin.net";
      const SLUG_TO_PAGE = ${JSON.stringify(this.SLUG_TO_PAGE)};
      ...

the line I added that fixed the issue

  window.CONFIG.domainBaseUrl = "https://startup.wentin.net";

how to found this code? what file should i open?

Click Worker - Manage Workers - Choose the workers that you made before - Quick Edit Check this link, read Create a script for Cloudflare Worker. They have more explanations of how to do it.

Nothing, this code neither works for me. Guess I'll have to check something different from Fruition.

harryghgim commented 2 years ago

Entiendo tu situaci贸n, acabo de probar este c贸digo con mis trabajadores y ellos funcionan, solo tienes que editar el c贸digo. CORRECCI脫N DE C脫DIGO: https://gist.github.com/isjair/7f3f243d229de2873eb612129216288e

Gracias por su ayuda. Sin embargo, a pesar de que copi茅 exactamente el mismo c贸digo, solo cambi茅 el dominio y la, y todav铆a no funciona. 驴Puedes decirme que hay algo que deber铆a hacer de otra manera, o cambiar algo de mi proveedor de dominio, godaddY?

If you verify your domain provider and that everything is fine since the error that I get is that you cannot access the same domain you have, now if you have it from cloudflare verify the dns and you have deleted the cache in development mode and Go into private mode in the browser and check if you have access, if you do not have access there is an error from the provider in some configuration.

Because if the domain will work, it will send you the page with a very common baseurl error, but since it is not, then it is assumed that it is from a provider to cloudflare or the other way around. Greetings

Thanks. Using a different brower than the one I used before I changed config, incognito mode or safari instead of chrome, worked for me.