yangshun-tech-interview-han.../apps/website/functions/grind75/[[catchall]].js
2024-09-17 20:06:14 +08:00

14 lines
425 B
JavaScript

const SOURCE_HOST = 'https://grind75.vercel.app';
export async function onRequest(context) {
const { request } = context;
// Define the original and target paths
const url = new URL(request.url);
// Rewrite to the new domain, preserving the original path and query string
const newURL = SOURCE_HOST + url.pathname + url.search;
// Fetch the content from the new domain
return await fetch(newURL, request);
}