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

@@ -1,5 +1,6 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
import type {NextRequest} from "next/server";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
@@ -99,4 +100,33 @@ export const formatKst = (
return `${yyyy}-${MM}-${dd} ${HH}:${mm}:${ss}`;
};
export const isBlank = (v?: string | null) => !v || v.trim().length === 0;
export const isBlank = (v?: string | null) => !v || v.trim().length === 0;
export const getClientIp = (req: NextRequest): string | null => {
const h = req.headers;
// 가장 흔한 케이스: 프록시/호스팅이 넣어줌
const xff = h.get("x-forwarded-for");
if (xff) {
// "client, proxy1, proxy2" 형태. 보통 첫 번째가 client IP로 쓰이지만,
// 프록시가 헤더를 덮어쓰지 않고 append만 하는 환경이면 spoof 가능성 있음.
return xff.split(",")[0].trim();
}
// 일부 인프라/프록시에서 쓰는 헤더들
const xRealIp = h.get("x-real-ip");
if (xRealIp) return xRealIp.trim();
// (Cloudflare 등) 사용 환경이면
const cf = h.get("cf-connecting-ip");
if (cf) return cf.trim();
// RFC 7239 Forwarded: for=1.2.3.4;proto=https;by=...
const forwarded = h.get("forwarded");
if (forwarded) {
const m = forwarded.match(/for="?([^;,\s"]+)"?/i);
if (m?.[1]) return m[1];
}
return null;
}