auth cookie

This commit is contained in:
2025-07-19 12:07:15 +09:00
parent db001315b7
commit 9ff9e832ea
3 changed files with 53 additions and 13 deletions
@@ -1,5 +1,5 @@
'use client'
import { deleteData, getData } from '@/components/lib/api'
import { deleteData, getData, useCookieAuth } from '@/components/lib/api'
import { UiTable, downloadExcel, downloadExcelWithKoreanHeaders } from '@common/business_components/ui'
import { zodResolver } from '@hookform/resolvers/zod'
import { useState, useEffect } from 'react'
@@ -86,7 +86,7 @@ const Result = () => {
// setCurPage(1);
handleSearchButtonClick();
}, [])
const auth = useCookieAuth();
const handleSearchButtonClick = async (customFormValues?: Partial<ResultFormValues>) => {
setIsLoadingResult(true);
setResetSelection(true);
@@ -113,6 +113,7 @@ const Result = () => {
"sggCd": formValues.sggCd,
"swageTmplntCd": processedSwageTmplntCd,
// "swtrmtZoneCd": formValues.swtrmtZoneCd,
"auth" : auth,
};
} else {
inftwtAnlsSearchDto = {
@@ -123,6 +124,7 @@ const Result = () => {
"sggCd": formValues.sggCd?.val === '0' ? null : formValues.sggCd?.val,
"swageTmplntCd": processedSwageTmplntCd,
// "swtrmtZoneCd": formValues.swtrmtZoneCd === '0' ? null : formValues.swtrmtZoneCd,
"auth" : auth,
};
}
console.log("Search DTO:", inftwtAnlsSearchDto);
+27 -1
View File
@@ -1,4 +1,5 @@
const BASE_URL = 'http://con.mind-one.co.kr:11083/sewerage-service/api';
import {useState, useEffect} from 'react';
const BASE_URL = process.env.NEXT_PUBLIC_SEWERAGE_API_URL || "";
export const postData = async (url: string, data: object): Promise<any> => {
const options: RequestInit = {
@@ -79,4 +80,29 @@ export const deleteData = async (url: string, data?: object): Promise<any> => {
const res = await fetch(url.startsWith('/') ? `${url}` : `${BASE_URL}/${url}`, options);
if (res.status === 204) return true
return res;
};
export function getCookie(name:string) {
const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
if (match && match[2]) {
return decodeURIComponent(match[2]);
}
return null;
}
export const useCookieAuth = () => {
const [data, setData] = useState("");
useEffect(() => {
const fetch = async () => {
const result = getCookie("Authorization");
if (result) {
setData(result);
}
};
fetch();
console.log("useCookieAuth 호출");
}, []);
return data;
};
+22 -10
View File
@@ -323,6 +323,9 @@ importers:
'@common/components':
specifier: workspace:*
version: link:../../packages/common/components
'@fontsource-variable/noto-sans-kr':
specifier: ^5.2.5
version: 5.2.5
'@frontend-opensource/use-react-hooks':
specifier: ^1.1.4
version: 1.1.4
@@ -341,6 +344,9 @@ importers:
'@tanstack/react-query':
specifier: ^5.67.1
version: 5.67.1(react@18.3.1)
'@tanstack/react-query-devtools':
specifier: ^5.75.5
version: 5.75.5(@tanstack/react-query@5.67.1)(react@18.3.1)
'@tanstack/react-table':
specifier: ^8.21.2
version: 8.21.2(react-dom@18.3.1)(react@18.3.1)
@@ -362,15 +368,6 @@ importers:
next:
specifier: 15.1.7
version: 15.1.7(react-dom@18.3.1)(react@18.3.1)
ol:
specifier: ^7.3.0
version: 7.5.2
ol-ext:
specifier: ^4.0.11
version: 4.0.31(ol@7.5.2)
proj4:
specifier: ^2.9.0
version: 2.15.0
react-chartjs-2:
specifier: ^5.3.0
version: 5.3.0(chart.js@4.4.8)(react@18.3.1)
@@ -532,6 +529,9 @@ importers:
'@hookform/resolvers':
specifier: ^4.1.3
version: 4.1.3(react-hook-form@7.54.2)
'@minoru/react-dnd-treeview':
specifier: 3.5.1-alpha.1
version: 3.5.1-alpha.1(dnd-core@16.0.1)(react-dnd@16.0.1)(react-dom@18.3.1)(react@18.3.1)
'@radix-ui/react-label':
specifier: ^2.1.2
version: 2.1.2(@types/react-dom@18.3.5)(@types/react@18.3.18)(react-dom@18.3.1)(react@18.3.1)
@@ -562,12 +562,24 @@ importers:
lucide-react:
specifier: ^0.474.0
version: 0.474.0(react@18.3.1)
ol:
specifier: ^7.3.0
version: 7.5.2
ol-ext:
specifier: ^4.0.11
version: 4.0.31(ol@7.5.2)
path:
specifier: ^0.12.7
version: 0.12.7
proj4:
specifier: ^2.9.0
version: 2.15.0
react-day-picker:
specifier: ^8.10.1
version: 8.10.1(date-fns@3.6.0)(react@18.3.1)
react-dnd:
specifier: ^16.0.1
version: 16.0.1(@types/node@22.13.9)(@types/react@18.3.18)(react@18.3.1)
react-dropzone:
specifier: ^14.3.8
version: 14.3.8(react@18.3.1)
@@ -2544,7 +2556,7 @@ packages:
dnd-multi-backend: 8.1.2(dnd-core@16.0.1)
framer-motion: 11.18.2(react-dom@18.3.1)(react@18.3.1)
react: 18.3.1
react-dnd: 16.0.1(@types/node@22.13.5)(@types/react@18.3.18)(react@18.3.1)
react-dnd: 16.0.1(@types/node@22.13.9)(@types/react@18.3.18)(react@18.3.1)
react-dnd-html5-backend: 16.0.1
react-dnd-touch-backend: 16.0.1
react-dom: 18.3.1(react@18.3.1)