Skip to content

Commit e6b1a04

Browse files
committed
feat: NODE_ENV 환경변수 추가
1 parent 145b908 commit e6b1a04

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
run: |
1818
docker build \
1919
--build-arg VITE_API_URL=${{ secrets.VITE_API_URL }} \
20+
--build-arg NODE_ENV=${{ secrets.NODE_ENV }} \
2021
-t ${{secrets.DOCKERHUB_REPO}} .
2122
docker tag ${{secrets.DOCKERHUB_REPO}}:latest ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_REPO}}:latest
2223
docker push ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_REPO}}:latest
@@ -32,6 +33,7 @@ jobs:
3233
sudo docker pull ${{secrets.DOCKERHUB_USERNAME}}/${{secrets.DOCKERHUB_REPO}}:latest
3334
sudo docker run \
3435
-e VITE_API_URL=${{ secrets.VITE_API_URL }} \
36+
-e NODE_ENV=${{ secrets.NODE_ENV }} \
3537
-v /etc/letsencrypt:/etc/letsencrypt:ro \
3638
-d -p 80:80 -p 443:443 \
3739
--name ${{secrets.DOCKERHUB_REPO}} \

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ COPY . .
1515

1616
# build-time ARG 정의
1717
ARG VITE_API_URL
18+
ARG NODE_ENV
19+
1820
ENV VITE_API_URL=$VITE_API_URL
21+
ENV NODE_ENV=$NODE_ENV
1922

2023
# Vite로 빌드
2124
RUN echo "VITE_API_URL=$VITE_API_URL"

src/utils/api.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
import apiClient from './axiosConfig';
33
import { AxiosResponse } from 'axios';
44

5+
const { NODE_ENV } = import.meta.env;
6+
const apiUrl = NODE_ENV === 'prod' ? 'https://cs25.co.kr' : 'http://localhost:8080';
7+
58
// Axios wrapper for consistency with existing code
69
async function apiRequest<T>(
710
endpoint: string,
@@ -153,9 +156,7 @@ export const quizAPI = {
153156

154157
// AI 피드백 SSE 스트리밍 (주관식)
155158
streamAiFeedback: (answerId: string, onData: (data: string) => void, onComplete: () => void, onError: (error: Event) => void) => {
156-
const { NODE_ENV } = import.meta.env;
157-
const API_BASE_URL = NODE_ENV === 'prod' ? 'https://cs25.co.kr' : 'http://localhost:8080';
158-
const eventSource = new EventSource(`${API_BASE_URL}/quizzes/answers/${answerId}/feedback-sentence`, { withCredentials: true });
159+
const eventSource = new EventSource(`${apiUrl}/quizzes/answers/${answerId}/feedback-sentence`, { withCredentials: true });
159160

160161
eventSource.onmessage = (event) => {
161162
onData(event.data);
@@ -257,8 +258,6 @@ export const authAPI = {
257258

258259
// 소셜 로그인
259260
socialLogin: async (provider: 'kakao' | 'github' | 'naver') => {
260-
const { NODE_ENV } = import.meta.env;
261-
const apiUrl = NODE_ENV === 'prod' ? "https://cs25.co.kr" : "http://localhost:8080";
262261
window.location.href = `${apiUrl}/oauth2/authorization/${provider}`;
263262
}
264263
};

src/utils/axiosConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ apiClient.interceptors.response.use(
7474

7575
// HttpOnly 쿠키 기반 토큰 재발급 시도
7676
// refreshToken은 HttpOnly 쿠키에 있으므로 자동으로 포함됨
77-
const response = await axios.post(`${API_BASE_URL}/auth/reissue`, {
77+
await axios.post(`${API_BASE_URL}/auth/reissue`, {
7878
// ReissueRequestDto - 백엔드에서 요구하는 형식에 맞춤
7979
// 만약 빈 객체도 허용한다면 이대로, 특정 필드가 필요하면 추가
8080
}, {

0 commit comments

Comments
 (0)