Skip to content

Instantly share code, notes, and snippets.

@ayosec
Created March 19, 2022 14:17
Show Gist options
  • Save ayosec/2448991cde635c7fd35c5734e5cf7367 to your computer and use it in GitHub Desktop.
Save ayosec/2448991cde635c7fd35c5734e5cf7367 to your computer and use it in GitHub Desktop.
Function for CloudFlare Pages to use an `index.txt` file as the main page.
// Path: <root>/functions/index.js
export async function onRequest(ctx) {
const url = new URL(ctx.request.url);
return await fetch(`${url.origin}/index.txt`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment