shrirambalaji
05/21/2023, 11:35 PMts
export default {
async fetch(request: {
url: string | URL; headers: { get: (arg0: string) => string }
}, env: any, ctx: any) {
try {
const subdomain = request.headers.get('host').split('.')[0];
// ... map subdomain to id
const destinationURL = new URL(`http://localhost:3001/${id}`);
const response = await fetch(destinationURL);
const proxyResponse = new Response(response.body, { headers: response.headers, status: response.status, statusText: response.statusText})
return proxyResponse
} catch (error) {
return new Response(null, { status: 404, statusText: "Oops can't find that page" });
}
},
};
What am I missing here?
https://cdn.discordapp.com/attachments/1109987865154310245/1109987865603084288/image.png▾