Skip to content

Commit 3080821

Browse files
committed
Revert "Merge pull request #218 from PNUMeat/fix/realtime-response-recovery"
This reverts commit 858c155, reversing changes made to 839ba58.
1 parent 858c155 commit 3080821

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3313
-11838
lines changed

.github/workflows/develop-cd.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ jobs:
2727
- name: Checkout code
2828
uses: actions/checkout@v3
2929
with:
30-
fetch-depth: 0
31-
ref: ${{ github.head_ref || github.ref || github.event.inputs.branch || 'test' }}
30+
ref: ${{ github.event.inputs.branch || github.ref_name }}
3231

3332
- name: Set up Node.js
3433
uses: actions/setup-node@v3
@@ -73,8 +72,8 @@ jobs:
7372
- name: Invalidate CloudFront Cache
7473
run: |
7574
aws cloudfront create-invalidation \
76-
--distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} \
77-
--paths "/*"
75+
--distribution-id ${{ secrets.CLOUDFRONT_ID }} \
76+
--paths "/index.html" "/"
7877
env:
7978
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
8079
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

bundles.html

Lines changed: 0 additions & 4949 deletions
This file was deleted.

package-lock.json

Lines changed: 2753 additions & 5443 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
"react-calendar": "^5.1.0",
3030
"react-dom": "^18.3.1",
3131
"react-hot-toast": "^2.5.2",
32-
"react-icons": "^5.5.0",
33-
"react-markdown": "^10.1.0",
3432
"react-router-dom": "^7.0.1",
3533
"react-slick": "^0.30.3",
3634
"slick-carousel": "^1.8.1"
@@ -61,7 +59,7 @@
6159
"vite-plugin-pwa": "^0.21.1",
6260
"workbox-build": "^7.3.0",
6361
"workbox-cacheable-response": "^7.3.0",
64-
"workbox-cli": "^2.1.3",
62+
"workbox-cli": "^7.3.0",
6563
"workbox-expiration": "^7.3.0",
6664
"workbox-precaching": "^7.3.0",
6765
"workbox-routing": "^7.3.0",

src/App.tsx

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/api/apiInstance.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { handleCookieOnRedirect } from '@/utils/cookie';
2+
13
import { NavigateFunction } from 'react-router-dom';
24

3-
import { API_BASE_URL } from '@/api/config';
45
import { ServerIntendedError } from '@/api/types';
56
import { PATH } from '@/routes/path';
67
import axios, {
@@ -27,7 +28,7 @@ const processQueue = (error: AxiosError | null): void => {
2728
if (error) {
2829
prom.reject(error);
2930
} else {
30-
prom.resolve(apiInstance(prom.config));
31+
prom.resolve(axios(prom.config));
3132
}
3233
});
3334

@@ -45,8 +46,7 @@ export const navigate = (path: string) => {
4546
};
4647

4748
const apiInstance: AxiosInstance = axios.create({
48-
baseURL: `${API_BASE_URL}/api/`,
49-
withCredentials: true,
49+
baseURL: `/api/`,
5050
headers: {
5151
'Content-Type': 'application/json',
5252
},
@@ -55,9 +55,9 @@ const apiInstance: AxiosInstance = axios.create({
5555

5656
apiInstance.interceptors.request.use(
5757
(config) => {
58-
// 헤더가 남아있을 경우 삭제
59-
if (config.headers?.Authorization) {
60-
delete config.headers.Authorization;
58+
const token = sessionStorage.getItem('Authorization');
59+
if (token) {
60+
config.headers.Authorization = `Bearer ${token}`;
6161
}
6262
return config;
6363
},
@@ -92,6 +92,7 @@ apiInstance.interceptors.response.use(
9292
if (error.response.status === 401) {
9393
if (code === 100) {
9494
navigate(PATH.ENROLL);
95+
9596
return Promise.reject(error);
9697
}
9798

@@ -111,12 +112,15 @@ apiInstance.interceptors.response.use(
111112
return apiInstance
112113
.post('v1/reissue')
113114
.then(() => {
115+
handleCookieOnRedirect();
116+
114117
processQueue(null);
115118
return apiInstance(originalRequest);
116119
})
117120
.catch((reissueError: AxiosError) => {
118121
processQueue(reissueError);
119-
// navigate(PATH.LOGIN);
122+
sessionStorage.removeItem('Authorization');
123+
navigate(PATH.LOGIN);
120124

121125
console.error('reissue error', reissueError);
122126
return Promise.reject(reissueError);
@@ -128,6 +132,7 @@ apiInstance.interceptors.response.use(
128132

129133
// 리프레시 토큰이 만료됨
130134
// sessionStorage.removeItem('Authorization');
135+
// navigate(PATH.LOGIN);
131136
return Promise.reject(error);
132137
}
133138
}

src/api/config.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/api/dashboard.ts

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import { isDevMode } from '@/utils/cookie.ts';
2+
3+
import { subjectMock, teamArticlesMock, teamInfoMock } from '@/api/mocks.ts';
4+
15
import apiInstance from './apiInstance';
26
import { ITeamInfo } from './team';
37
import { ServerResponse } from './types';
@@ -28,31 +32,12 @@ export interface IArticle {
2832

2933
export interface IArticlesByDateResponse {
3034
content: IArticle[];
31-
empty: boolean;
32-
first: boolean;
33-
last: boolean;
34-
number: number;
35-
numberOfElements: number;
36-
pageable: {
37-
offset: number;
38-
pageNumber: number;
39-
pageSize: number;
40-
paged: boolean;
41-
unpaged: boolean;
42-
sort: {
43-
empty: boolean;
44-
sorted: boolean;
45-
unsorted: boolean;
46-
};
35+
page: {
36+
size: number;
37+
number: number;
38+
totalElements: number;
39+
totalPages: number;
4740
};
48-
size: number;
49-
sort: {
50-
empty: boolean;
51-
sorted: boolean;
52-
unsorted: boolean;
53-
};
54-
totalElements: number;
55-
totalPages: number;
5641
}
5742

5843
export interface ITopicResponse {
@@ -73,6 +58,12 @@ export const getTeamInfoAndTags = async (
7358
year: number,
7459
month: number
7560
): Promise<ITeamInfoAndTagsResponse> => {
61+
if (isDevMode()) {
62+
await new Promise((r) => setTimeout(r, 1000));
63+
64+
return teamInfoMock.data;
65+
}
66+
7667
const res = await apiInstance.get<ServerResponse<ITeamInfoAndTagsResponse>>(
7768
`/v1/teams/${teamId}/team-page`,
7869
{ params: { year, month } }
@@ -86,6 +77,10 @@ export const getArticlesByDate = async (
8677
date: string,
8778
page: number
8879
): Promise<IArticlesByDateResponse> => {
80+
if (isDevMode()) {
81+
return teamArticlesMock.data;
82+
}
83+
8984
const res = await apiInstance.get<ServerResponse<IArticlesByDateResponse>>(
9085
`/v1/articles/${teamId}/by-date`,
9186
{ params: { date, page } }
@@ -98,6 +93,10 @@ export const getTeamTopic = async (
9893
teamId: number,
9994
date: string
10095
): Promise<ITopicResponse> => {
96+
if (isDevMode()) {
97+
return subjectMock.data;
98+
}
99+
101100
const res = await apiInstance.get<ServerResponse<ITopicResponse>>(
102101
`/v1/articles/teams/${teamId}/subjects`,
103102
{ params: { date } }

src/api/image.ts

Lines changed: 0 additions & 96 deletions
This file was deleted.

src/api/mypage.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import { isDevMode } from '@/utils/cookie.ts';
2+
13
import apiInstance from '@/api/apiInstance';
4+
import { myArticlesMock, myPageTeamMock } from '@/api/mocks.ts';
25
import { ServerResponse } from '@/api/types';
36

47
export type TeamAbstraction = {
@@ -9,9 +12,9 @@ export type TeamAbstraction = {
912
};
1013

1114
export const queryMyTeamInfo = async () => {
12-
// if (isDevMode()) {
13-
// return myPageTeamMock.data;
14-
// }
15+
if (isDevMode()) {
16+
return myPageTeamMock.data;
17+
}
1518

1619
const res =
1720
await apiInstance.get<ServerResponse<TeamAbstraction[]>>(
@@ -46,9 +49,9 @@ export type MyArticleResponse = {
4649
};
4750

4851
export const queryMyArticles = async (teamId: number, page: number) => {
49-
// if (isDevMode()) {
50-
// return myArticlesMock.data;
51-
// }
52+
if (isDevMode()) {
53+
return myArticlesMock.data;
54+
}
5255

5356
const res = await apiInstance.get<ServerResponse<MyArticleResponse>>(
5457
`v1/articles/${teamId}/my-page`,

0 commit comments

Comments
 (0)