🐛 Fix 404
This commit is contained in:
parent
2f283d0a24
commit
afa8b02c10
@ -9,11 +9,14 @@ export const prerender = false;
|
|||||||
const { slug } = Astro.params;
|
const { slug } = Astro.params;
|
||||||
|
|
||||||
const response = await fetch(`https://feed.smartsheep.studio/api/posts/${slug}`);
|
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"];
|
const post = (await response.json())["data"];
|
||||||
|
|
||||||
if (!post) {
|
if (post.realm_id != parseInt(process.env.PUBLIC_REALM_ID ?? "0")) {
|
||||||
return Astro.redirect("/404");
|
|
||||||
} else if (post.realm_id != parseInt(process.env.PUBLIC_REALM_ID ?? "0")) {
|
|
||||||
return Astro.redirect(`https://feed.smartsheep.studio/posts/${post.id}`);
|
return Astro.redirect(`https://feed.smartsheep.studio/posts/${post.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user