로컬로그인시 api접속가능 middleware

This commit is contained in:
2025-10-14 00:51:13 +00:00
parent 17befab4c0
commit 76db85a22f
2 changed files with 21 additions and 2 deletions

View File

@@ -6,11 +6,21 @@ import type { NextRequest } from "next/server";
export default auth(async (req) => {
// 경로 추출
const { pathname } = req.nextUrl;
// 로컬 접속 확인 (특정 경로만 우회)
const isLocal = req.headers.get('host')?.includes('localhost') ||
req.headers.get('host')?.includes('127.0.0.1');
if (isLocal && pathname.startsWith("/api/contents")) {
return NextResponse.next();
}
// 세션 가져오기
const session = req.auth;
const { pathname } = req.nextUrl;
if (pathname.startsWith("/admin")) {
const email = session?.user?.email;