2021-02-06

Cloudflare Workers

 06 Feb 2021  Snippets

Cloudflare Workers

Proxy URL
addEventListener("fetch", (event) => {
  event.respondWith(
     fetch("https://paramdeo.com")
  );
});
Return HTML

Pass an entire HTML document as a variable in a Worker script:

async function handleRequest(request) {
  const init = {
    headers: {
      'content-type': 'text/html;charset=UTF-8',
    },
  }
  return new Response(someHTML, init)
}
addEventListener('fetch', event => {
  return event.respondWith(handleRequest(event.request))
})
const someHTML =  `
<!doctype html>
<html lang="en">
  <head>
  ...
`
Webmentions & Comments

Copyright © Paramdeo Singh. Made with ☕️ in Guyana. All Rights Reserved.

Last Site Build on Tue, 30 Nov 2021 19:17:38 -0500

1MB Club Badge

Paramdeo Singh Guyana

Riding the wave of consciousness in this treacherous mortal sea.

Technology Design Strategy Literature Personal Blogs