Skip to content

Instantly share code, notes, and snippets.

@zerolab
Created March 30, 2020 08:09
Show Gist options
  • Save zerolab/0e9cbbce14e9490babc86c1289a61046 to your computer and use it in GitHub Desktop.
Save zerolab/0e9cbbce14e9490babc86c1289a61046 to your computer and use it in GitHub Desktop.
Cloudflare Worker holding page
addEventListener("fetch", event => {
event.respondWith(fetchAndReplace(event.request))
})
async function fetchAndReplace(request) {
let modifiedHeaders = new Headers()
modifiedHeaders.set('Content-Type', 'text/html')
modifiedHeaders.append('Pragma', 'no-cache')
const holdingPage = await fetch(holdingPageUrl)
const content = await holdingPage.text();
// Return modified response.
return new Response(content, {
headers: modifiedHeaders
})
}
const holdingPageUrl = "https://example.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment