Created
March 19, 2022 14:17
-
-
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.
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
// 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