Website Masking Worker
index.tsTypeScript
index.ts
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const url = new URL(request.url);
const targetURL = `https://milindmishra.com${url.pathname}`;
// Fetch content from the target URL
const response = await fetch(targetURL, {
headers: {
...Object.fromEntries(request.headers),
Host: 'milindmishra.com',
},
});
// Return the proxied response
return new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: response.headers,
});
},
} satisfies ExportedHandler<Env>;
Updated: 11/26/2024