Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus.
export default { async fetch(request, env, ctx) { try { // Alright, first things first, let's grab that URL from the request const url = new URL(request.url); let path = url.pathname;
// Time to split the path into pieces and ditch anything after the first bit // We're making sure not to trip over any leading slashes by filtering out the empties let segments = path.split('/').filter(segment => segment !== "");
// If we've got more than just the one segment, it means we've got extra stuff in the URL // We're only interested in the first part, so let's cut the rest out if (segments.length > 1) { path = '/' + segments[0]; // Just like that, we're back to our base path }
// With our cleaned-up path, let's stitch together our target URL const targetUrl = `https://cmsish.webflow.io${path}`;
// Now, we fetch the content from our neatly crafted URL const response = await fetch(targetUrl); let content = await response.text(); // Assuming what we're getting back is HTML
// Lastly, we respond with the page content we got return new Response(content, { headers: { "Content-Type": "text/html" } // Gotta make sure we're telling browsers it's HTML }); } catch (e) { // Oops, if something goes haywire, we need to let someone know return new Response('Whoopsie-daisy! Ran into a snag: ' + e.message, { status: 500 }); } }};