260312_01_ENH: Error 페이지 및 Redirect 페이지 구현

This commit is contained in:
2026-03-12 09:36:09 +09:00
parent bedcfbc9d1
commit f7ce249aa7
17 changed files with 710 additions and 6 deletions

View File

@@ -45,7 +45,7 @@ const LoginPage = () => {
const err = apiError(e);
if (err.status === 401 || err.status === 403) setError("아이디 또는 비밀번호를 다시 확인해주세요.");
else if (err.code === NONE_HTTP_ERROR) setError("알 수 없는 오류가 발생했습니다. 잠시 후 다시 시도해주세요.");
else setError(`로그인에 실패했습니다. (status: ${err.status})`);
else setError(`로그인에 실패했습니다. (${err.message})`);
}
}

View File

@@ -0,0 +1,37 @@
import RedirectLanding from "@/components/external/RedirectLanding";
import {notFound} from "next/navigation";
import {ALLOW_REDIRECT} from "@/const/commonConst";
import {RedirectSlug} from "@/types/common";
type redirectPageProps = {
params: Promise<{ slug: string }>;
searchParams?: Promise<Record<string, string | string[] | undefined>>;
}
const toRedirectSlug = (slug: string): RedirectSlug | null => {
return ALLOW_REDIRECT.has(slug.toLowerCase()) ? (slug.toLowerCase() as RedirectSlug) : null;
}
const redirectPage = async ({
params,
searchParams,
}: redirectPageProps) => {
const { slug } = await params;
const sp = searchParams ? await searchParams : undefined;
//미들 웨어에서 처리
console.log(sp);
const redirectSlug = toRedirectSlug(slug);
console.log(redirectSlug);
if (!redirectSlug) notFound();
return (
<RedirectLanding redirectSlug={redirectSlug} />
)
}
export default redirectPage;

View File

@@ -0,0 +1,35 @@
import ErrorPage from "@/components/external/Error";
import {ErrorCode} from "@/types/common";
function toErrorCode(raw: string | undefined): ErrorCode {
if (raw === "500") return "500";
// fetch_error, 기타 알 수 없는 코드 → 500으로 처리
if (raw && raw !== "404") return "500";
return "404";
}
type RedirectErrorPageProps = {
searchParams: Promise<Record<string, string | string[] | undefined>>;
};
const RedirectErrorPage = async ({ searchParams }: RedirectErrorPageProps) => {
const sp = await searchParams;
console.log(sp)
const code = toErrorCode(sp.code as string | undefined);
const sid = (sp.sid as string | undefined) ?? "";
return (
<ErrorPage
code={code}
errorDescription={
sid
? `오류가 발생했습니다. 관리자에게 문의할 경우 아래 코드를 전달해 주세요.\n리스트 ID : ${sid}`
: undefined
}
/>
)
}
export default RedirectErrorPage