Open monicacoaching opened 4 years ago
Hi @monicacoaching have you correctly created the routes in the CloudFlare configuration?
They are needed in order to route correctly the calls made by the browsers and make the magic of the worker script happen.
Holler if you need help!
Luca
Not sure if I did that right. I just followed the instructions. I also looked at the video too but Not working. Is there a common step people do incorrectly? Is there any way to veryfy what was wrong?
On Sat, Jun 6, 2020 at 6:35 PM Luca Bertagnolio notifications@github.com wrote:
Hi @monicacoaching https://github.com/monicacoaching have you correctly created the routes in the CloudFlare configuration?
They are needed in order to route correctly the calls made by the browsers and make the magic of the worker script happen.
Holler if you need help!
Luca
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stephenou/fruitionsite/issues/17#issuecomment-640021145, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3LYVATDOWGM5QJLOMCOVTRVIEVXANCNFSM4NVNTZRA .
I suspect you did not configure correctly the DNS entries on CloudFlare.
They should be configured like so:
The worker script seems fine, but there must also be the route entry correctly configured.
In your case the route should be like so:
*monicacoaching.com/*
with the correct worker script name configured.
Hope this help, let me know how it goes.
Bye, Luca
Do you need to type the * at the beginning too?
Now i have Monicacoaching.com/*
Should i have monicacoaching.com/ ?
I’ll check the cloudfare DNS records
On Sun, Jun 7, 2020 at 6:19 AM Luca Bertagnolio notifications@github.com wrote:
I suspect you did not configure correctly the DNS entries on CloudFlare.
They should be configured like so:
[image: lux-screenshot0760] https://user-images.githubusercontent.com/5642245/83954698-b15e9200-a84b-11ea-9180-507eec1facfd.png
The worker script seems fine, but there must also be the route entry correctly configured.
In your case the route should be like so:
monicacoaching.com/
with the correct worker script name configured.
Hope this help, let me know how it goes.
Bye, Luca
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stephenou/fruitionsite/issues/17#issuecomment-640119541, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3LYVCSEHMC2WJQUCP2553RVKXG3ANCNFSM4NVNTZRA .
If you put the asterisk at the beginning too, that single character will allow two things:
This is the simple reason for that character, nothing more. Clever, huh? ;-)
The DNS records were clearly not there when I checked yesterday, hence the script could not be triggered. I am convinced you're on the way to solving the issue!
Bye, Luca
What should I put for the IP address in the DNS management? Thx, Monica
On Sun, Jun 7, 2020 at 6:19 AM Luca Bertagnolio notifications@github.com wrote:
I suspect you did not configure correctly the DNS entries on CloudFlare.
They should be configured like so:
[image: lux-screenshot0760] https://user-images.githubusercontent.com/5642245/83954698-b15e9200-a84b-11ea-9180-507eec1facfd.png
The worker script seems fine, but there must also be the route entry correctly configured.
In your case the route should be like so:
monicacoaching.com/
with the correct worker script name configured.
Hope this help, let me know how it goes.
Bye, Luca
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stephenou/fruitionsite/issues/17#issuecomment-640119541, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3LYVCSEHMC2WJQUCP2553RVKXG3ANCNFSM4NVNTZRA .
Is this ok? It still doesn't work. : (
@monicacoaching I messaged you privately on your Facebook page yesterday, not sure if you have seen those messages.
Dear Luca, Thanks for letting me know. I just checked my fb msgs. At this moment, I’m not able to spend much so will use a different way to get the domain. Thank you so much for your help so far.
Monica
On Mon, Jun 8, 2020 at 3:49 PM Luca Bertagnolio notifications@github.com wrote:
@monicacoaching https://github.com/monicacoaching I messaged you privately on your Facebook page yesterday, not sure if you have seen those messages.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/stephenou/fruitionsite/issues/17#issuecomment-640404120, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3LYVGHI3RUXBHZ6HCSMDTRVSCX3ANCNFSM4NVNTZRA .
Thanks a ton for your comments here. Finally my website up by changing the A records.
Didn't work for me. Still get Mismatch between origin and baseUrl (dev) error. I've tried a lot of ways (www. stuff, changing DNS settings on Cloudflare, etc) and nothing worked.
It's not working for me either...Can anybody help?
Hi there, I saw your video with Marie and I followed the instructions on your site, I think. I created the worker on cloudfare. www.monicacoaching.com still gives me error. I checked google domains (where i have the domain) and updated the servers. Any ideas, why it's not working? Thank you so much. I am an English teacher based in Seoul.
Below is my code:
/ CONFIGURATION STARTS HERE /
/ Step 1: enter your domain name like fruitionsite.com / const MY_DOMAIN = 'monicacoaching.com';
/*
The value on the right is the Notion page ID */ const SLUG_TO_PAGE = { '': 'b12b2afd767e4b309bd6274ffd8a03b8', 'emails': '4a991d04dfac41da8e8ed1559a5870c0', };
/ 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)); });
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); const notionUrl = 'https://www.notion.so' + url.pathname; let response; if (url.pathname.startsWith('/app') && url.pathname.endsWith('js')) { response = await fetch(notionUrl); 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'); } else if ((url.pathname.startsWith('/api'))) { // Forward API response = await fetch(notionUrl, { 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', '*'); } 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(notionUrl, { 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); }