대민 미들웨어 경유
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ NEXT_PUBLIC_ACCESS_TOKEN = access-token
|
||||
NEXT_PUBLIC_REFRESH_TOKEN = refresh-token
|
||||
NEXT_PUBLIC_PORT = 3005
|
||||
#NEXT_PUBLIC_PROXY_HOST = http://con.mind-one.co.kr:11035
|
||||
NEXT_PUBLIC_PROXY_HOST = http://localhost:3005/
|
||||
NEXT_PUBLIC_PROXY_HOST = http://localhost:3005
|
||||
NEXT_PUBLIC_DM_SERVER_API_URL = http://con.mind-one.co.kr:11080/api/v1
|
||||
NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000
|
||||
NEXT_PUBLIC_FO_SERVER_API_URL = http://con.mind-one.co.kr:11082/api/v1
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
|
||||
/**
|
||||
* 관망도 API
|
||||
*/
|
||||
const API_URL = `${process.env.NEXT_PUBLIC_SEWERAGE_API_URL}/v1/map`
|
||||
const REUSE_API_URL = `${process.env.NEXT_PUBLIC_REUSE_API_URL}`
|
||||
import { DEV_URL_WR, DEV_URL_SN } from "@/components/ui/config";
|
||||
const PROXY_HOST = process.env.NEXT_PUBLIC_PROXY_HOST || "";
|
||||
|
||||
export type LyrStngProps = {
|
||||
lyr_sn: string
|
||||
@@ -31,7 +30,7 @@ export type LyrStngProps = {
|
||||
export const mapService = {
|
||||
//레이어 설정 조회
|
||||
getLyrStngs: async () => {
|
||||
const response = await fetch(`${API_URL}/lyrStngs/DM_NETWORK`, {
|
||||
const response = await fetch(`${PROXY_HOST}${DEV_URL_SN}/app/v1/map/lyrStngs/DM_NETWORK`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
@@ -45,7 +44,7 @@ export const mapService = {
|
||||
return response.json();
|
||||
},
|
||||
getPbnstRuseFclts: async (ruseFcltPk:any) => {
|
||||
const response = await fetch(`${REUSE_API_URL}/reuseFc/pubFc/${ruseFcltPk}`, {
|
||||
const response = await fetch(`${PROXY_HOST}${DEV_URL_WR}/api/v1/reuseFc/pubFc/${ruseFcltPk}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import { AUTH_USER_ID, CLAIM_NAME } from "@/src/shared/config";
|
||||
import { fetchType, getFetch } from "@/components/ui/api";
|
||||
import { DEV_URL_FO } from "@/components/ui/config";
|
||||
import { getCookie } from "@common/components/lib/cookie";
|
||||
import type { FacilityInfo, SubsInfo } from "./type";
|
||||
|
||||
const PROXY_HOST = process.env.NEXT_PUBLIC_PROXY_HOST;
|
||||
const tokenId = getCookie(AUTH_USER_ID);
|
||||
const Authorization = getCookie(CLAIM_NAME);
|
||||
|
||||
const checkWrRegList = async () => {
|
||||
const wrRegList = await getFetch(fetchType.WR, `/reuseFc/pubFc`);
|
||||
return wrRegList;
|
||||
@@ -22,10 +28,12 @@ const getRuseFclt = async (
|
||||
url = url + `/${searchTxt}`;
|
||||
}
|
||||
|
||||
const response = await fetch(DEV_URL_FO + url, {
|
||||
const response = await fetch(PROXY_HOST + DEV_URL_FO + url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
[AUTH_USER_ID]: tokenId ?? "",
|
||||
[CLAIM_NAME]: Authorization ?? "",
|
||||
},
|
||||
body: JSON.stringify(ruseList),
|
||||
});
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
//8880
|
||||
import { AUTH_USER_ID, CLAIM_NAME } from "@/src/shared/config";
|
||||
import { DEV_URL_FO, DEV_URL_WR } from "../config";
|
||||
import { getCookie } from "@common/components/lib/cookie";
|
||||
|
||||
const PROXY_HOST = process.env.NEXT_PUBLIC_PROXY_HOST;
|
||||
const tokenId = getCookie(AUTH_USER_ID);
|
||||
const Authorization = getCookie(CLAIM_NAME);
|
||||
|
||||
export const fetchType = {
|
||||
COMMON: "common",
|
||||
@@ -13,10 +19,13 @@ interface RequestParams {
|
||||
|
||||
export const getFetch = async (type: string, url: string) => {
|
||||
const baseUrl = type === fetchType.FO ? DEV_URL_FO : DEV_URL_WR;
|
||||
const response = await fetch(baseUrl + url, {
|
||||
console.log("호출주소 ", PROXY_HOST+baseUrl + url);
|
||||
const response = await fetch(PROXY_HOST+baseUrl + url, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
accept: "application/json",
|
||||
[AUTH_USER_ID]: tokenId ?? "",
|
||||
[CLAIM_NAME]: Authorization ?? "",
|
||||
},
|
||||
});
|
||||
|
||||
@@ -28,10 +37,12 @@ export const getFetch = async (type: string, url: string) => {
|
||||
};
|
||||
|
||||
export const postFetch = async (url: string, params: RequestParams) => {
|
||||
const response = await fetch(DEV_URL_WR + url, {
|
||||
const response = await fetch(PROXY_HOST+DEV_URL_WR + url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
[AUTH_USER_ID]: tokenId ?? "",
|
||||
[CLAIM_NAME]: Authorization ?? "",
|
||||
},
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
@@ -43,10 +54,12 @@ export const postFetch = async (url: string, params: RequestParams) => {
|
||||
};
|
||||
|
||||
export const putFetch = async (url: string, params: RequestParams) => {
|
||||
const response = await fetch(DEV_URL_WR + url, {
|
||||
const response = await fetch(PROXY_HOST+DEV_URL_WR + url, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
[AUTH_USER_ID]: tokenId ?? "",
|
||||
[CLAIM_NAME]: Authorization ?? "",
|
||||
},
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
@@ -58,10 +71,12 @@ export const putFetch = async (url: string, params: RequestParams) => {
|
||||
};
|
||||
|
||||
export const deleteFetch = async (url: string, params: RequestParams) => {
|
||||
const response = await fetch(DEV_URL_WR + url, {
|
||||
const response = await fetch(PROXY_HOST+DEV_URL_WR + url, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
[AUTH_USER_ID]: tokenId ?? "",
|
||||
[CLAIM_NAME]: Authorization ?? "",
|
||||
},
|
||||
body: JSON.stringify(params),
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { PROXY_HOST, SERVER_API_FO_URL, SERVER_API_WR_URL } from "@/src/shared/config/env";
|
||||
import { PROXY_HOST } from "@/src/shared/config/env";
|
||||
|
||||
export const LOCAL_URL = PROXY_HOST;
|
||||
export const DEV_URL_FO = SERVER_API_FO_URL;
|
||||
export const DEV_URL_WR = SERVER_API_WR_URL;
|
||||
export const DEV_URL_FO = "/operation-service";
|
||||
export const DEV_URL_WR = "/reuse-service";
|
||||
export const DEV_URL_SN = "/sewerage-service";
|
||||
|
||||
+24
-3
@@ -1,5 +1,6 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { CLAIM_NAME, AUTH_USER_ID } from "./src/shared/config";
|
||||
import { SERVER_API_FO_URL, SERVER_API_WR_URL } from "./src/shared/config/env";
|
||||
|
||||
// const CLAIM_NAME = "Authorization";
|
||||
// const AUTH_USER_ID = "token-id";
|
||||
@@ -115,12 +116,30 @@ export function middleware(req: NextRequest) {
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
}
|
||||
|
||||
if (pathname.startsWith("/sewerage-service")) {
|
||||
if (pathname.startsWith("/reuse-service")) {
|
||||
const queryParams = searchParams.toString();
|
||||
const newUrl = `${SEWERAGE_API_URL}${pathname.replace("/sewerage-service/api", "")}${
|
||||
const newUrl = `${SERVER_API_WR_URL}${pathname.replace("/reuse-service", "")}${
|
||||
queryParams ? `?${queryParams}` : ""
|
||||
}`;
|
||||
console.log(`[Middleware] Rewriting from '/geoserver' path to: ${newUrl}`);
|
||||
console.log(`[Middleware] Rewriting from '/reuse-service' path to: ${newUrl}`);
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
}
|
||||
|
||||
if (pathname.startsWith("/operation-service")) {
|
||||
const queryParams = searchParams.toString();
|
||||
const newUrl = `${SERVER_API_FO_URL}${pathname.replace("/operation-service", "")}${
|
||||
queryParams ? `?${queryParams}` : ""
|
||||
}`;
|
||||
console.log(`[Middleware] Rewriting from '/operation-service' path to: ${newUrl}`);
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
}
|
||||
|
||||
if (pathname.startsWith("/sewerage-service")) {
|
||||
const queryParams = searchParams.toString();
|
||||
const newUrl = `${SEWERAGE_API_URL}${pathname.replace("/sewerage-service", "")}${
|
||||
queryParams ? `?${queryParams}` : ""
|
||||
}`;
|
||||
console.log(`[Middleware] Rewriting from '/sewerage-service' path to: ${newUrl}`);
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
}
|
||||
if (pathname.startsWith("/bussiness-juso-service")) {
|
||||
@@ -150,6 +169,8 @@ export const config = {
|
||||
"/user-service/:path*",
|
||||
"/attach-service/:path*",
|
||||
"/geoserver/:path*",
|
||||
"/operation-service/:path*",
|
||||
"/reuse-service/:path*",
|
||||
"/sewerage-service/:path*",
|
||||
"/bussiness-juso-service/:path*",
|
||||
"/",
|
||||
|
||||
+1
-1
@@ -14,5 +14,5 @@ NEXT_PUBLIC_ACCESS_TOKEN = access-token
|
||||
NEXT_PUBLIC_REFRESH_TOKEN = refresh-token
|
||||
NEXT_PUBLIC_NGII_URL = https://map.ngii.go.kr/openapi/Gettile.do?apiKey=04trYP9_xwLAfALjwZ-B8g
|
||||
NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API
|
||||
NEXT_PUBLIC_DC_URL = https://apigateway.apps.rsonesoft.com
|
||||
NEXT_PUBLIC_DC_URL = https://apigateway.apps.rsonesoft.com/dc-service
|
||||
REACT_EDITOR=atom
|
||||
+23
-12
@@ -65,12 +65,12 @@ export function middleware(req: NextRequest) {
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
}
|
||||
|
||||
if (pathname.startsWith("/sewerage-service/api/v1/map/geometry")) {
|
||||
if (pathname.startsWith("/sewerage-service")) {
|
||||
const queryParams = searchParams.toString();
|
||||
const newUrl = `${SEWERAGE_API_URL}${pathname.replace("/sewerage-service/api", "")}${
|
||||
const newUrl = `${SEWERAGE_API_URL}${pathname.replace("/sewerage-service", "")}${
|
||||
queryParams ? `?${queryParams}` : ""
|
||||
}`;
|
||||
console.log(`[Middleware] Rewriting from '/geoserver' path to: ${newUrl}`);
|
||||
console.log(`[Middleware] Rewriting from '/sewerage-service' path to: ${newUrl}`);
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
}
|
||||
|
||||
@@ -110,12 +110,21 @@ export function middleware(req: NextRequest) {
|
||||
}
|
||||
|
||||
if (pathname.startsWith("/dc-service")) {
|
||||
const requestHeaders = new Headers(req.headers);
|
||||
const queryParams = searchParams.toString();
|
||||
const newUrl = `${DC_URL}${pathname.replace("/dc-service", "")}${
|
||||
queryParams ? `?${queryParams}` : ""
|
||||
}`;
|
||||
console.log(`[Middleware] Rewriting from '/dc-service' path to: ${newUrl}`);
|
||||
return NextResponse.rewrite(new URL(newUrl));
|
||||
|
||||
const token = req.cookies.get(CLAIM_NAME)?.value;
|
||||
const userId = req.cookies.get(AUTH_USER_ID)?.value;
|
||||
if (token) requestHeaders.set(CLAIM_NAME, token);
|
||||
if (userId) requestHeaders.set(AUTH_USER_ID, userId);
|
||||
|
||||
return NextResponse.rewrite(new URL(newUrl), {
|
||||
headers: requestHeaders,
|
||||
});
|
||||
}
|
||||
|
||||
if (pathname.startsWith("/user-service")) {
|
||||
@@ -138,13 +147,15 @@ export function middleware(req: NextRequest) {
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
"/",
|
||||
"/server/:path*",
|
||||
"/geoserver/:path*",
|
||||
"/attach-service/:path*",
|
||||
"/user-service/:path*",
|
||||
"/cms-service/:path*",
|
||||
"/operation-service/:path*",
|
||||
"/reuse-service/:path*",
|
||||
"/",
|
||||
"/server/:path*",
|
||||
"/geoserver/:path*",
|
||||
"/sewerage-service/:path*",
|
||||
"/attach-service/:path*",
|
||||
"/user-service/:path*",
|
||||
"/cms-service/:path*",
|
||||
"/operation-service/:path*",
|
||||
"/reuse-service/:path*",
|
||||
"/dc-service/:path*",
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user