Skip to content

Commit ce21771

Browse files
authored
Merge pull request #163 from kakao-tech-campus-3rd-step3/fix/dev-proxy-config-error#162
[FIX] 개발 환경 프록시 순환 참조 문제 해결 및 설정 개선
2 parents 69e7f35 + 1891f7d commit ce21771

File tree

9 files changed

+23
-19
lines changed

9 files changed

+23
-19
lines changed

src/pages/admin/ApplicationDetail/api/comments.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Comment } from '@/pages/admin/ApplicationDetail/types/comments';
22

33
export const fetchComments = async (applicationId: number): Promise<Comment[]> => {
4-
const url = `/api/applications/${applicationId}/comments`;
4+
const url = `${import.meta.env.VITE_API_BASE_URL}/applications/${applicationId}/comments`;
55
const response = await fetch(url);
66

77
if (!response.ok) throw new Error('Failed to fetch comments');
@@ -13,7 +13,8 @@ export const createComment = async (
1313
content: string,
1414
rating: number,
1515
): Promise<Comment> => {
16-
const url = `/api/applications/${applicationId}/comments`;
16+
const url = `${import.meta.env.VITE_API_BASE_URL}/applications/${applicationId}/comments`;
17+
1718
const response = await fetch(url, {
1819
method: 'POST',
1920
headers: {
@@ -27,7 +28,7 @@ export const createComment = async (
2728
};
2829

2930
export const deleteComment = async (applicationId: number, commentId: number): Promise<void> => {
30-
const url = `/api/applications/${applicationId}/comments/${commentId}`;
31+
const url = `${import.meta.env.VITE_API_BASE_URL}/applications/${applicationId}/comments/${commentId}`;
3132
const response = await fetch(url, {
3233
method: 'DELETE',
3334
});
@@ -41,7 +42,7 @@ export const updateComment = async (
4142
content: string,
4243
rating: number,
4344
): Promise<Comment> => {
44-
const url = `/api/applications/${applicationId}/comments/${commentId}`;
45+
const url = `${import.meta.env.VITE_API_BASE_URL}/applications/${applicationId}/comments/${commentId}`;
4546
const response = await fetch(url, {
4647
method: 'PATCH',
4748
headers: {

src/pages/admin/ApplicationDetail/api/detailApplication.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const fetchDetailApplication = async (
44
clubId: number,
55
applicantId: number,
66
): Promise<DetailApplication> => {
7-
const url = `/api/clubs/${clubId}/applicants/${applicantId}/application`;
7+
const url = `${import.meta.env.VITE_API_BASE_URL}/clubs/${clubId}/applicants/${applicantId}/application`;
88
const response = await fetch(url);
99

1010
if (!response.ok) throw new Error('지원서 상세 정보를 가져오지 못했습니다');
@@ -15,7 +15,7 @@ export const updateApplicationStatus = async (
1515
applicationId: number,
1616
status: DetailApplication['status'],
1717
): Promise<unknown> => {
18-
const url = `/api/applications/${applicationId}`;
18+
const url = `${import.meta.env.VITE_API_BASE_URL}/applications/${applicationId}`;
1919
const response = await fetch(url, {
2020
method: 'PATCH',
2121
headers: {

src/pages/admin/ClubDetailEdit/api/clubDetailEdit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import type { ClubDetailEdit } from '../types/clubDetailEdit';
22

33
export const fetchClubDetailEdit = async (clubId: string | number): Promise<ClubDetailEdit> => {
4-
const url = `/api/clubs/${clubId}`;
4+
const url = `${import.meta.env.VITE_API_BASE_URL}/clubs/${clubId}`;
55
const response = await fetch(url);
66

77
if (!response.ok) {
88
throw new Error('동아리 상세 수정 데이터를 가져오는데 실패했습니다.');
99
}
1010
return response.json() as Promise<ClubDetailEdit>;
1111
};
12+
1213
export const updateClubDetailEdit = async (
1314
clubId: string | number,
1415
updatedData: Partial<ClubDetailEdit>,
1516
): Promise<ClubDetailEdit> => {
16-
const url = `/api/clubs/${clubId}`;
17+
const url = `${import.meta.env.VITE_API_BASE_URL}/clubs/${clubId}`;
1718
const response = await fetch(url, {
1819
method: 'POST',
1920
headers: {

src/pages/admin/Dashboard/api/applicant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ApplicantData } from '@/pages/admin/Dashboard/types/dashboard';
22

33
export const fetchApplicants = async (clubId: number): Promise<ApplicantData[]> => {
4-
const url = `/api/clubs/${clubId}/dashboard/applicants`;
4+
const url = `${import.meta.env.VITE_API_BASE_URL}/clubs/${clubId}/dashboard/applicants`;
55
const response = await fetch(url);
66

77
if (!response.ok) {

src/pages/admin/Dashboard/api/dashboard.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { DashboardSummary } from '@/pages/admin/Dashboard/types/dashboard';
22

33
export const fetchDashboardSummary = async (clubId: number): Promise<DashboardSummary> => {
4-
const response = await fetch(`/api/clubs/${clubId}/dashboard`);
4+
const url = `${import.meta.env.VITE_API_BASE_URL}/clubs/${clubId}/dashboard`;
5+
const response = await fetch(url);
56

67
if (!response.ok) {
78
throw new Error('대시보드 요약 정보를 불러오는 데 실패했습니다.');

src/pages/user/Apply/api/apply.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
} from '@/pages/user/Apply/type/apply.ts';
77

88
export const fetchApplicationForm = async (Id: number): Promise<ApplicationForm> => {
9-
const url = `/api/clubs/${Id}/apply`;
9+
const url = `${import.meta.env.VITE_API_BASE_URL}/clubs/${Id}/apply`;
1010
const response = await fetch(url);
1111

1212
if (!response.ok) throw new Error('지원서 양식을 가져오지 못했습니다');
@@ -20,7 +20,7 @@ export const postApplicationForm = async (
2020
): Promise<ApplicationFormRequest> => {
2121
const applicationDto = applicationFormDto(formData, questionArray);
2222

23-
const url = `/api/clubs/${clubId}/apply-submit`;
23+
const url = `${import.meta.env.VITE_API_BASE_URL}/clubs/${clubId}/apply-submit`;
2424
const response = await fetch(url, {
2525
method: 'POST',
2626
headers: {
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import type { ClubDetail } from '../types/clubDetail';
22

33
export const fetchClubDetail = async (clubId: number): Promise<ClubDetail> => {
4-
const url = `/api/clubs/${clubId}`;
5-
const res = await fetch(url);
4+
const url = `${import.meta.env.VITE_API_BASE_URL}/clubs/${clubId}`;
5+
const response = await fetch(url);
66

7-
if (!res.ok) {
7+
if (!response.ok) {
88
throw new Error('동아리 상세 정보를 가져오는데 실패했습니다.');
99
}
10-
11-
return res.json() as Promise<ClubDetail>;
10+
return response.json() as Promise<ClubDetail>;
1211
};

src/pages/user/Main/api/club.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export type ClubResponse = {
66
};
77

88
export async function getClubsByCategory(filter: ClubCategoryEng): Promise<ClubResponse> {
9-
const response = await fetch(import.meta.env.VITE_API_BASE_URL + `/clubs?category=${filter}`);
9+
const url = `${import.meta.env.VITE_API_BASE_URL}/clubs?category=${filter}`;
10+
const response = await fetch(url);
11+
1012
return await response.json();
1113
}

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default ({ mode }: ConfigEnv) => {
2020
server: {
2121
proxy: {
2222
'/api': {
23-
target: env.VITE_API_BASE_URL,
23+
target: env.VITE_PROXY_TARGET,
2424
changeOrigin: true,
2525
secure: false,
2626
},

0 commit comments

Comments
 (0)