Created
January 13, 2024 14:12
-
-
Save journey-ad/3be51033a3d7ce20e95a9fa3cff942e0 to your computer and use it in GitHub Desktop.
cf-pages-proxy
This file contains hidden or 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
export default { | |
async fetch(request, env) { | |
const url = new URL(request.url); | |
if (url.pathname.startsWith('/')) { | |
url.hostname = env.PROXY_URL; | |
const new_request = new Request(url, request); | |
return fetch(new_request); | |
} | |
return env.ASSETS.fetch(request); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment