Created
March 30, 2020 08:09
-
-
Save zerolab/0e9cbbce14e9490babc86c1289a61046 to your computer and use it in GitHub Desktop.
Cloudflare Worker holding page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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