임시 commit
This commit is contained in:
@@ -13,6 +13,18 @@ const OPERATION_API_URL = process.env.NEXT_PUBLIC_FO_SERVER_API_URL || "";
|
||||
const BUSINESS_JUSO_API_URL = process.env.NEXT_PUBLIC_FINDADRESS_URL || "";
|
||||
const AdressKey = process.env.NEXT_PRIVATE_WR_ADDRESS_KEY || "";
|
||||
|
||||
/** 공통: URLSearchParams의 값을 decodeURIComponent 적용하여 querystring 생성 */
|
||||
function toDecodedQueryString(params: URLSearchParams): string {
|
||||
const entries: string[][] = Array.from(params.entries()).map(([k, v]) => {
|
||||
try {
|
||||
return [k, decodeURIComponent(v)] as string[];
|
||||
} catch {
|
||||
return [k, v] as string[];
|
||||
}
|
||||
});
|
||||
return new URLSearchParams(entries).toString();
|
||||
}
|
||||
|
||||
/** 공통: 요청 헤더에 쿠키 기반 인증 값 주입 */
|
||||
function buildAuthHeaders(req: NextRequest): Headers {
|
||||
const requestHeaders = new Headers(req.headers);
|
||||
@@ -160,6 +172,12 @@ export function middleware(req: NextRequest) {
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
}
|
||||
|
||||
if (pathname.startsWith("/ngii-server")) {
|
||||
const decodedQuery = toDecodedQueryString(searchParams);
|
||||
const newUrl = `${process.env.NEXT_PUBLIC_NGII_URL}${pathname.replace("/ngii-server", "")}${decodedQuery ? `?${decodedQuery}` : ""}`;
|
||||
console.log(`[Middleware] Rewriting from '${pathname}' path to: ${newUrl}`);
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
@@ -175,6 +193,7 @@ export const config = {
|
||||
"/reuse-service/:path*",
|
||||
"/operation-service/:path*",
|
||||
"/bussiness-juso-service/:path*",
|
||||
"/ngii-server/:path*",
|
||||
"/"
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user