diff --git a/apps/dm/.env.production b/apps/dm/.env.production index 6f3cabc41..23cde9181 100644 --- a/apps/dm/.env.production +++ b/apps/dm/.env.production @@ -13,7 +13,7 @@ NEXT_PUBLIC_CS_SERVER_API_URL = http://apigateway.iipbs-was.svc.cluster.local:80 NEXT_PUBLIC_CS_TUS_UPLOAD = /attach-service/api/v1/tus/upload NEXT_PUBLIC_GEOSERVER_URL = http://172.29.143.87:8080/geoserver NEXT_PUBLIC_LX_GEOSERVER_URL = http://172.29.143.87:8080/geoserver_swl -NEXT_PUBLIC_REUSE_API_URL= http://apigateway.iipbs-was.svc.cluster.local:8000/reuse-service/api/v1 +NEXT_PUBLIC_WR_API_URL= http://apigateway.iipbs-was.svc.cluster.local:8000/reuse-service/api/v1 NEXT_PUBLIC_SEWERAGE_API_URL = http://apigateway.iipbs-was.svc.cluster.local:8000/sewerage-service NEXT_PUBLIC_NGII_URL = http://172.29.143.87 NEXT_PUBLIC_NGII_PARAM = BDE2BEF39DAFEC293AB6730150F222AC&service=WMTS&request=GetTile&version=1.0.0&format=image/png&layer=korean_map&style=korean&tilematrixset=korean&tilematrix={z}&tilecol={y}&tilerow={x} diff --git a/apps/wr/app/(without-layout)/stats/hasuStat/page.tsx b/apps/wr/app/(without-layout)/stats/hasuStat/page.tsx index ee568e75a..1d2bf2eb3 100644 --- a/apps/wr/app/(without-layout)/stats/hasuStat/page.tsx +++ b/apps/wr/app/(without-layout)/stats/hasuStat/page.tsx @@ -23,10 +23,11 @@ export default function HasuStatPage() { alert("Client IP:" + ip); const is10 = /^10\./.test(ip); - setStatus(is10 ? "redirect-internal" : "redirect-root"); + const is172 = /^172\./.test(ip); + setStatus(is10||is172 ? "redirect-internal" : "redirect-root"); // Use location.replace so user can't go back to this page - if (is10) { + if (is10||is172) { // redirect to internal IP window.open('http://10.101.163.102:8888/cms/lay1/WS10000014/program.do', '_blank'); } else { diff --git a/apps/wr/app/api/client-ip/route.ts b/apps/wr/app/api/client-ip/route.ts index f883ba9d1..016700fe7 100644 --- a/apps/wr/app/api/client-ip/route.ts +++ b/apps/wr/app/api/client-ip/route.ts @@ -2,11 +2,26 @@ import { NextResponse } from 'next/server'; export async function GET(request: Request) { const headers = request.headers; - // Prefer x-forwarded-for (may be comma separated list) - const xff = headers.get('x-forwarded-for') ?? headers.get('x-real-ip') ?? ''; - let ip = ''; - if (xff && xff.length > 0) { - ip = String(xff).split(',')[0].trim(); + // 1. x-forwarded-for 또는 x-real-ip에서 IP 추출 + let ip = headers.get('x-forwarded-for') || headers.get('x-real-ip') || ''; + + // IP가 있으면 첫 번째 IP 주소만 추출 + if (ip) { + if (ip.includes(',')) { + ip = ip.split(',')[0]?.trim()||''; + } else { + ip = ip.trim(); + } + } + + // 3. IPv6 주소 정규화 + if (ip.startsWith('::ffff:')) { + ip = ip.replace('::ffff:', ''); + } + + // 4. localhost IPv6를 IPv4로 변환 + if (ip === '::1') { + ip = '127.0.0.1'; } return NextResponse.json({ ip });