-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from b-and-it/9/feat
9/feat Completed Form Page
- Loading branch information
Showing
69 changed files
with
3,916 additions
and
20,388 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,75 @@ | ||
import axios from 'axios' | ||
import store from '../store/store' | ||
import { parseKSTDate } from '../utils/time'; | ||
|
||
const { useAuthStorePersist } = store; | ||
|
||
export const BASE_URL = process.env.REACT_APP_API_URL | ||
|
||
export const axiosSecureAPI = axios.create({ | ||
baseURL: BASE_URL, | ||
headers: { 'Content-Type': 'application/json' }, | ||
}); | ||
|
||
export const axiosAPI = axios.create({ | ||
baseURL: BASE_URL, | ||
headers: { 'Content-Type': 'application/json' }, | ||
}); | ||
}); | ||
|
||
axiosSecureAPI.interceptors.request.use(config => { | ||
|
||
const { accessToken } = useAuthStorePersist.getState(); | ||
|
||
if (accessToken !== null) { | ||
config.headers.Authorization = `Bearer ${accessToken}`; | ||
} | ||
return config; | ||
}, error => { | ||
return Promise.reject(error); | ||
}); | ||
|
||
// 응답 인터셉터 추가 | ||
axiosSecureAPI.interceptors.response.use( | ||
response => response, // 정상 응답이면 그대로 반환 | ||
async error => { | ||
const originalRequest = error.config; | ||
if (error.response.status === 400 && !originalRequest._retry) { | ||
const { refreshToken, refreshTokenExpireTime } = useAuthStorePersist.getState(); | ||
const currentTime = new Date().getTime(); | ||
|
||
// if (refreshTokenExpireTime !== null && currentTime > refreshTokenExpireTime.getTime()){ | ||
// useAuthStorePersist.getState().setTokens(null, null,null,null); | ||
// window.location.href = '/' | ||
// alert('토큰이 만료되었습니다. 다시 로그인해 주세요.') | ||
// return Promise.reject(error); | ||
// } | ||
if(refreshToken === null || refreshTokenExpireTime === null){ | ||
useAuthStorePersist.getState().setTokens(null, null,null,null); | ||
window.location.href = '/' | ||
alert('토큰이 없습니다. 다시 로그인해 주세요.') | ||
} | ||
originalRequest._retry = true; | ||
try { | ||
|
||
const tokenResponse = await axiosAPI.post('/api/tokens/reissue', null, { | ||
params : { | ||
refresh: refreshToken | ||
} | ||
} ); | ||
const result = tokenResponse.data.result; | ||
const accessToken = result.accessToken; | ||
const newrefreshToken = result.refreshToken; | ||
const accessTokenExpireTime = parseKSTDate(result.code_expire); | ||
const refreshTokenExpireTime = parseKSTDate(result.refresh_expire); | ||
useAuthStorePersist.getState().setTokens(accessToken, newrefreshToken, accessTokenExpireTime, refreshTokenExpireTime); | ||
originalRequest.headers.Authorization = `Bearer ${accessToken}`; | ||
return axiosSecureAPI(originalRequest); | ||
} catch (refreshError) { | ||
return Promise.reject(refreshError); | ||
} | ||
} | ||
return Promise.reject(error); | ||
} | ||
); | ||
|
||
export default axiosSecureAPI; |
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/components/search/searchbox.tsx → src/main/components/search/searchbox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
src/components/search/searchcard.tsx → src/main/components/search/searchcard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Oops, something went wrong.