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 +1,42 @@
//외부 설문에 뎐동 되는 API
//외부 설문에 뎐동 되는 API
import {NextRequest, NextResponse} from "next/server";
import {RouteContext} from "@/types/common";
import {createContactApi} from "@/lib/server-api";
import {errorToResponse} from "@/lib/http-util";
import {getClientIp} from "@/lib/utils";
export const POST = async (req: NextRequest, context: RouteContext) => {
try {
const { searchParams } = new URL(req.url);
const {slug = []} = await context.params;
const [action] = slug;
console.log(slug)
const sid = (searchParams.get("sid") ?? "").trim();
const allowAction = ["start", "complete", "screen", "quota"]
if(slug.length === 1 && allowAction.includes(action.toLowerCase()) && sid.length > 0){
const contactApi = await createContactApi();
const pathname = req.nextUrl.pathname;
const h = req.headers;
const log = {
remoteAddr: h.get("x-orig-ip") || getClientIp(req),
uri: h.get("x-orig-uri") || pathname,
url: h.get("x-orig-url") || req.url,
userAgent: h.get("x-orig-user-agent") || h.get("user-agent"),
referer: h.get("x-orig-referer") || h.get("referer"),
origin: h.get("x-orig-origin") || h.get("origin"),
xForwardedFor: h.get("x-forwarded-for"),
forwarded: h.get("forwarded"),
};
//Todo 수정 필요
return new NextResponse(null, { status: 204 });
}
return NextResponse.json({ message: "Not found" }, { status: 404 });
} catch (error: unknown) {
return errorToResponse(error);
}
};