diff --git a/functions/grapher/_middleware.ts b/functions/grapher/_middleware.ts new file mode 100644 index 0000000000..d392fb7ea6 --- /dev/null +++ b/functions/grapher/_middleware.ts @@ -0,0 +1,10 @@ +import { Env } from "../_common/env.js" +import { getRedirectForUrl } from "../_common/redirectTools.js" + +export const onRequest: PagesFunction = async (context) => { + const url = new URL(context.request.url) + console.log("Looking up redirect for", url.pathname) + const redirect = await getRedirectForUrl(context.env, url) + if (redirect) return redirect + return await context.next() +}