File tree Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Expand file tree Collapse file tree 2 files changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,11 @@ import axios from 'axios';
22import { axiosInstance } from './axios' ;
33import { useAuthStore } from '@/store/authStore' ;
44
5+ const API_BASE_URL =
6+ import . meta. env . MODE === 'development'
7+ ? '/api/auth/token' // ✅ 개발 환경에서는 프록시를 사용
8+ : import . meta. env . VITE_API_URL + '/api/auth/token' ; // ✅ 배포 환경에서는 직접 API 호출
9+
510// 로그인
611export const login = async ( loginId : string , password : string ) => {
712 const { data } = await axiosInstance . post ( '/auth/login' , {
@@ -25,7 +30,7 @@ export const postLogout = async () => {
2530
2631// 토큰 재발급
2732export const reissueToken = async ( ) => {
28- const { data } = await axios . post ( '/api/auth/token' , {
33+ const { data } = await axios . post ( ` ${ API_BASE_URL } ` , {
2934 withCredentials : true ,
3035 } ) ;
3136
Original file line number Diff line number Diff line change @@ -2,8 +2,13 @@ import axios from 'axios';
22import { useAuthStore } from '@/store/authStore' ;
33import { reissueToken } from '@/apis/auth' ;
44
5+ const API_BASE_URL =
6+ import . meta. env . MODE === 'development'
7+ ? '/api' // ✅ 개발 환경에서는 프록시를 사용
8+ : import . meta. env . VITE_API_URL + '/api' ; // ✅ 배포 환경에서는 직접 API 호출
9+
510export const axiosInstance = axios . create ( {
6- baseURL : '/api' ,
11+ baseURL : API_BASE_URL ,
712 withCredentials : true , // RT 자동 포함
813} ) ;
914
@@ -50,14 +55,3 @@ axiosInstance.interceptors.response.use(
5055 return Promise . reject ( error ) ;
5156 } ,
5257) ;
53-
54- // .env에 추가하기
55- // VITE_API_URL=http://43.203.98.65:8080
56-
57- // 사용예시
58- // const login = async () => {
59- // const data = await axiosInstance.post('/user/login', {
60- // loginId: 'test1234',
61- // password: 'test1234!',
62- // });
63- // };
You can’t perform that action at this time.
0 commit comments