View gist:7d5b559562af3993fe014faf06004493
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
export default { | |
async fetch(request, env) { | |
let url = new URL(request.url); | |
if (url.pathname.startsWith('/')) { | |
url.hostname="example.com"; | |
let new_request=new Request(url,request); | |
return fetch(new_request); | |
} | |
// Otherwise, serve the static assets. | |
return env.ASSETS.fetch(request); |