✨ feat: add service-down error page
This commit is contained in:
1
shared/assets/under-construction.svg
Normal file
1
shared/assets/under-construction.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 152 KiB |
@ -1,5 +1,6 @@
|
||||
"use server";
|
||||
import { headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import { UAParser } from "ua-parser-js";
|
||||
|
||||
export interface BackendResponse<T = unknown> {
|
||||
@ -22,22 +23,26 @@ export const backendFetch = async (path: string, options: RequestInit = {}) => {
|
||||
ip: userIp,
|
||||
};
|
||||
|
||||
const res = await fetch(`${process.env.BACKEND_ENDPOINT}/${path}`, {
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-client-info": JSON.stringify(clientInfo),
|
||||
Authorization: `Bearer ${process.env.BACKEND_API_KEY}`,
|
||||
...options.headers,
|
||||
},
|
||||
cache: "default",
|
||||
});
|
||||
try {
|
||||
const res = await fetch(`${process.env.BACKEND_ENDPOINT}/${path}`, {
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-client-info": JSON.stringify(clientInfo),
|
||||
Authorization: `Bearer ${process.env.BACKEND_API_KEY}`,
|
||||
...options.headers,
|
||||
},
|
||||
cache: "default",
|
||||
});
|
||||
|
||||
const resJson = (await res.json()) as BackendResponse;
|
||||
const resJson = (await res.json()) as BackendResponse;
|
||||
|
||||
if (!res.ok || !resJson.success) {
|
||||
throw new Error(`Elysia error: ${resJson.error}`);
|
||||
if (!res.ok || !resJson.success) {
|
||||
throw new Error(`Elysia error: ${resJson.error}`);
|
||||
}
|
||||
|
||||
return resJson;
|
||||
} catch (error) {
|
||||
redirect("/status?reason=backend-unreachable");
|
||||
}
|
||||
|
||||
return resJson;
|
||||
};
|
||||
|
||||
@ -15,28 +15,28 @@ const NavigationLink = () => {
|
||||
<div className="pl-10">
|
||||
<NavigationMenu viewport={false}>
|
||||
<NavigationMenuList className="flex-wrap">
|
||||
<NavigationMenuItem>
|
||||
<NavigationMenuItem key={1}>
|
||||
<NavigationMenuLink asChild>
|
||||
<Link href="/season" className="text-sm">
|
||||
Season
|
||||
</Link>
|
||||
</NavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
<NavigationMenuItem>
|
||||
<NavigationMenuItem key={2}>
|
||||
<NavigationMenuLink asChild>
|
||||
<Link href="/genres" className="text-sm">
|
||||
Genres
|
||||
</Link>
|
||||
</NavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
<NavigationMenuItem>
|
||||
<NavigationMenuItem key={3}>
|
||||
<NavigationMenuLink asChild>
|
||||
<Link href="/trending" className="text-sm">
|
||||
Trending
|
||||
</Link>
|
||||
</NavigationMenuLink>
|
||||
</NavigationMenuItem>
|
||||
<NavigationMenuItem>
|
||||
<NavigationMenuItem key={4}>
|
||||
<NavigationMenuTrigger className="font-normal">
|
||||
Media
|
||||
</NavigationMenuTrigger>
|
||||
@ -62,7 +62,7 @@ const NavigationLink = () => {
|
||||
</ul>
|
||||
</NavigationMenuContent>
|
||||
</NavigationMenuItem>
|
||||
<NavigationMenuItem>
|
||||
<NavigationMenuItem key={5}>
|
||||
<NavigationMenuTrigger className="font-normal">
|
||||
Release
|
||||
</NavigationMenuTrigger>
|
||||
|
||||
Reference in New Issue
Block a user