From 53beadef9dcc2f44a2efcf346cbfd4d1a01dde7c Mon Sep 17 00:00:00 2001 From: ljpark Date: Thu, 23 Oct 2025 20:10:10 +0900 Subject: [PATCH] =?UTF-8?q?dm=20=20middleware=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/dm/.env.local | 2 +- apps/dm/.env.mindone | 2 +- apps/dm/app/(popup-layout)/map/service/map.ts | 2 +- apps/dm/middleware.ts | 21 +++++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apps/dm/.env.local b/apps/dm/.env.local index 236b5b5ad..93ea58f01 100644 --- a/apps/dm/.env.local +++ b/apps/dm/.env.local @@ -13,7 +13,7 @@ NEXT_PUBLIC_CS_SERVER_API_URL = http://dev.onasys.co.kr:8000 NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver NEXT_PUBLIC_CS_TUS_UPLOAD = /attach-service/api/v1/tus/upload -NEXT_PUBLIC_REUSE_API_URL=http://con.mind-one.co.kr:11080/api/v1 +NEXT_PUBLIC_WR_SERVER_API_URL = http://con.mind-one.co.kr:11083/reuse-service/api/v1 NEXT_PUBLIC_NGII_URL = https://map.ngii.go.kr NEXT_PUBLIC_NGII_PARAM = 04trYP9_xwLAfALjwZ-B8g&service=WMTS&request=GetTile&version=1.0.0&format=image/png&layer=korean_map&style=korean&tilematrixset=korean&tilematrix={z}&tilecol={x}&tilerow={y} NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service # 개발 서버 API diff --git a/apps/dm/.env.mindone b/apps/dm/.env.mindone index 1b7c8cee8..1ca3ecfb6 100644 --- a/apps/dm/.env.mindone +++ b/apps/dm/.env.mindone @@ -10,7 +10,7 @@ NEXT_PUBLIC_CLAIM_NAME = Authorization NEXT_PUBLIC_AUTH_USER_ID = token-id NEXT_PUBLIC_ACCESS_TOKEN = access-token NEXT_PUBLIC_REFRESH_TOKEN = refresh-token -NEXT_PUBLIC_REUSE_API_URL=http://con.mind-one.co.kr:11080/api/v1 +NEXT_PUBLIC_WR_SERVER_API_URL = http://con.mind-one.co.kr:11083/reuse-service/api/v1 NEXT_PUBLIC_NGII_URL = https://map.ngii.go.kr NEXT_PUBLIC_NGII_PARAM = 04trYP9_xwLAfALjwZ-B8g&service=WMTS&request=GetTile&version=1.0.0&format=image/png&layer=korean_map&style=korean&tilematrixset=korean&tilematrix={z}&tilecol={x}&tilerow={y} NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service # 개발 서버 API diff --git a/apps/dm/app/(popup-layout)/map/service/map.ts b/apps/dm/app/(popup-layout)/map/service/map.ts index 9c10ca190..7701288bb 100644 --- a/apps/dm/app/(popup-layout)/map/service/map.ts +++ b/apps/dm/app/(popup-layout)/map/service/map.ts @@ -29,7 +29,7 @@ export type LyrStngProps = { export const mapService = { //레이어 설정 조회 getLyrStngs: async () => { - const response = await fetch(`${DEV_URL_SN}/app/v1/map/lyrStngs/DM_NETWORK`, { + const response = await fetch(`${DEV_URL_SN}/api/v1/map/lyrStngs/DM_NETWORK`, { method: 'GET', headers: { 'Accept': 'application/json', diff --git a/apps/dm/middleware.ts b/apps/dm/middleware.ts index b013082d3..ee26a9767 100644 --- a/apps/dm/middleware.ts +++ b/apps/dm/middleware.ts @@ -11,6 +11,18 @@ const SEWERAGE_API_URL = process.env.NEXT_PUBLIC_SEWERAGE_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(); +} + export function middleware(req: NextRequest) { const pathname = req.nextUrl.pathname; console.log(`[Middleware] Request URL: ${req.url}`); @@ -142,6 +154,14 @@ export function middleware(req: NextRequest) { console.log(`[Middleware] Rewriting from '/sewerage-service' path to: ${newUrl}`); 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)); + } + if (pathname.startsWith("/bussiness-juso-service")) { console.log("AdressKey ", AdressKey); const params = new URLSearchParams({ @@ -173,6 +193,7 @@ export const config = { "/reuse-service/:path*", "/sewerage-service/:path*", "/bussiness-juso-service/:path*", + "/ngii-server/:path*", "/", ], };