From afa8b02c102f14d992a1e6c25035c3479eab0738 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 10 Feb 2024 12:24:38 +0800 Subject: [PATCH] :bug: Fix 404 --- src/pages/posts/[slug].astro | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/posts/[slug].astro b/src/pages/posts/[slug].astro index e465524..960f9cd 100644 --- a/src/pages/posts/[slug].astro +++ b/src/pages/posts/[slug].astro @@ -9,11 +9,14 @@ export const prerender = false; const { slug } = Astro.params; const response = await fetch(`https://feed.smartsheep.studio/api/posts/${slug}`); + +if (response.status !== 200) { + return Astro.redirect("/404"); +} + const post = (await response.json())["data"]; -if (!post) { - return Astro.redirect("/404"); -} else if (post.realm_id != parseInt(process.env.PUBLIC_REALM_ID ?? "0")) { +if (post.realm_id != parseInt(process.env.PUBLIC_REALM_ID ?? "0")) { return Astro.redirect(`https://feed.smartsheep.studio/posts/${post.id}`); }