Skip to content

Commit

Permalink
Add middleware for grapher redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
rakyi committed Feb 14, 2025
1 parent 9d4d0a7 commit ce429ab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions functions/grapher/[slug].ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ const router = Router<
finally: [corsify],
})
router
.get("*", async (_, url, env) => {
console.log("Looking up redirect for", url.pathname)
const redirect = await getRedirectForUrl(env, url)
if (redirect) return redirect
// Don't return anything to pass to the next handler.
})
.get(
`/grapher/:slug${extensions.configJson}`,
async ({ params: { slug } }, { searchParams }, env, etag) =>
Expand Down

0 comments on commit ce429ab

Please sign in to comment.