From da8e77abe7a723d54fb012f7607e8cc906ce02f8 Mon Sep 17 00:00:00 2001 From: tmin002 Date: Wed, 4 Feb 2026 11:59:07 +0900 Subject: [PATCH] fix: redirect unauthenticated record access Skip server API call without cookies and redirect to login on auth errors. --- src/app/(with-container)/record/page.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/(with-container)/record/page.tsx b/src/app/(with-container)/record/page.tsx index 19adf82..8d8a5d0 100644 --- a/src/app/(with-container)/record/page.tsx +++ b/src/app/(with-container)/record/page.tsx @@ -2,10 +2,23 @@ import { Stack } from "@mui/material"; import RecentRecordSection from "./panel/RecentRecordSection"; import PastRecordsSection from "./panel/PastRecordsSection"; import { createAxiosServer } from "@/apis/createAxiosServer"; +import { headers } from "next/headers"; +import { redirect } from "next/navigation"; +import { isAuthError } from "@/apis/errors"; export default async function Record() { + const cookie = (await headers()).get("cookie") ?? ""; + if (!cookie) { + redirect("/login?next=%2Frecord"); + } + const api = await createAxiosServer(); - await api.get("/records"); + try { + await api.get("/records"); + } catch (e) { + if (isAuthError(e)) redirect("/login?next=%2Frecord"); + throw e; + } return (