Skip to content

Instantly share code, notes, and snippets.

Avatar

Iman Montajabi ImanMontajabi

View GitHub Profile
View gist:7d5b559562af3993fe014faf06004493
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);