website
git clone https://git.pyrossh.dev/website
木 Personal website of pyrossh. Built with astrojs, shiki, vite.
e70b046
— pyrossh
2026-07-07T11:58:59+05:30
fix: redirect /posts/ to /posts in blog detail worker
packages/workers/posts/detail/src/index.tsx
CHANGED
|
@@ -5,7 +5,10 @@ import type { Env } from "@pyrossh/types";
|
|
|
5
5
|
export default {
|
|
6
6
|
async fetch(request: Request, env: Env): Promise<Response> {
|
|
7
7
|
const url = new URL(request.url);
|
|
8
|
-
|
|
8
|
+
let postId = url.pathname.replace("/posts/", "").replace(/\/$/, "");
|
|
9
|
+
if (!postId) {
|
|
10
|
+
return Response.redirect(new URL("/posts", url.origin).toString(), 302);
|
|
11
|
+
}
|
|
9
12
|
const post = await getPost(env.REPOS, postId);
|
|
10
13
|
if (!post) {
|
|
11
14
|
return Response.redirect(`${url.origin}/404`, 302);
|