vite.config.js 832 Bytes
import { fileURLToPath, URL } from 'node:url';

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';

// https://vitejs.dev/config/
export default defineConfig(() => {
    return {
        plugins: [vue()],
        resolve: {
            alias: {
                '@': fileURLToPath(new URL('./src', import.meta.url)),
            },
        },
        server: {
            proxy: {
              '/api': {  //#1. axios라이브러리 등으로 http 요청인데 api로 시작하면,
                target: 'http://localhost:8080',  //#2. 이쪽 주소로 매핑하여 백그라운드로 보내라.
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, '/api'),
                secure: false,
                ws: true
              }
            }
        }
    };
});