diff --git a/src/api/axiosInstance.ts b/src/api/axiosInstance.ts index 14b53f7..4e949ff 100644 --- a/src/api/axiosInstance.ts +++ b/src/api/axiosInstance.ts @@ -9,7 +9,7 @@ interface IRefreshResponse { message: string; } export const axiosInstance = axios.create({ - baseURL: import.meta.env.VITE_API_BASE_URL, + baseURL: '/api', withCredentials: true, }); diff --git a/vite.config.ts b/vite.config.ts index 5a00583..490f43d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,17 +1,29 @@ import tailwindcss from '@tailwindcss/vite'; import react from '@vitejs/plugin-react-swc'; -import { defineConfig } from 'vite'; +import { defineConfig, loadEnv } from 'vite'; import svgr from 'vite-plugin-svgr'; -export default defineConfig({ - plugins: [react(), svgr({ include: '**/*.svg?react' }), tailwindcss()], - server: { - host: '0.0.0.0', - port: 5173, - }, - resolve: { - alias: { - '@': '/src', +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), ''); + const target = env.VITE_API_BASE_URL; + return { + plugins: [react(), svgr({ include: '**/*.svg?react' }), tailwindcss()], + server: { + host: '0.0.0.0', + port: 5173, + proxy: { + '/api': { + target, + changeOrigin: true, + secure: true, + rewrite: (path) => path.replace(/^\/api/, ''), + }, + }, }, - }, + resolve: { + alias: { + '@': '/src', + }, + }, + }; });