Open Nicholas2271 opened 2 years ago
You got error "Mismatch between origin and baseUrl ( dev)" Fix: Change this line in your code window.CONFIG.domainBaseUrl = 'https://${MY_DOMAIN}'; to window.CONFIG.domainBaseUrl = location.origin;
See how they fix "Mismatch between origin and baseUrl ( dev)" in here #140
In DNS Just add A record @ point to 1.1.1.1 (do not turn on proxy cloudflare in proxy status column)
do I delete the one I already have in the DNS?
I changed what u told me in the DNS and removed the other one but it shows this
delete the CNAME record and try again
I did and now it appears this
Check your worker is working well
the worker is going amazing but when I use it on my browser even in incognito mode it won't load
In this Did you setup the route like this? your_domain.com/*
In my case, I also disable subdomain like this in workers and just on for my domain
like this?
Yeah. That's it
it still won't work it says that the site can't be reached, I also disabled the other one.
Try clear cache "Purge cache"
it still won't work
it works for u?
yeah maybe you have to clear cache in your browser
it doesn't show on my phone I'm confused
So weird =))) I checked your website in my laptop and my phone It's working well
omg is it too much to ask if u send a pic of the website in ur phone?
If your phone can't update the notion app latest version in appstore or ch play. You can't see your website in your phone
I recommend you check your website on laptop On mobile is 50 - 50
I've checked in another browser but it won't appear
I do not comprehend why won't it show up to me
In browser, does it show error?
yes it does, I've tried in 3 but this is what it shows
do not add www just type cattaleyaconfecciones.com
because you just point cattaleyaconfecciones.com Your DNS does not have record to www
it seems my browser adds automatically the www
just test first
I did and still won't
I literally do not type the www yet it sends me to that
If browser automatically adds www just delete it
even if I remove it, it still does, is there a way I could add the www so it could load?
If you want to add www
In DNS, add A record www point to 1.1.1.1
In workers Route Change cattaleyaconfecciones.com/ to .cattaleyaconfecciones.com/*
without the asterisk? also it won't let me just add the dot before the domain
also I added the www and it showed up the same
Did you add like this?
here
this?
yup try purge cache again I can't see your website currently
oh ok
Did it work?
done purging and nothing happened
I saw your website. It's working well Can you take the photo showing your link website in search address? Like this
uhmm seem like your website has been blocked by internet provider.
woah what
I just bought a domain in namecheap. I followed all the steps and even deleted the A type DNS that my domain already had and changed it to 1.1.1.1 and tried my website and it gave Error 520. because of this I changed it back to the A type DNS it had as u can see in the picture below but it won't work either idk what the problem could be. when I add the "www." before my domain it actually appears something like the 3rd image. Idk what I'm doing wrong so someone please help me. It also appears this mismatch thing in the 4th image.
Here's the code I used in case of needed. / CONFIGURATION STARTS HERE /
/ Step 1: enter your domain name like fruitionsite.com / const MY_DOMAIN = 'cattaleyaconfecciones.com';
/*
The value on the right is the Notion page ID */ const SLUG_TO_PAGE = { '': '42d0e49d4a9049cbbc52095cd406ddca', 'catalogo': '7ba17268587040c88efbfc7abf1ac850', 'contactanos': 'd4e9027902fd4743bdb467d90fcacb1b', 'sobre-nosotros': 'f239ed72cd1c4419b32d19be6e45fd2b', 'haz-tus-pedidos': 'cf12b739c2bb4555bc4378b61f249e12', };
/ Step 3: enter your page title and description for SEO purposes / const PAGE_TITLE = ''; const PAGE_DESCRIPTION = '';
/ 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 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(` ${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); }