import { fileURLToPath, URL } from 'node:url'

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

// https://vite.dev/config/
export default defineConfig({
  base: './',
  plugins: [
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  server: {
    port: 5001, // 设置开发服务器的端口号
    host: 'localhost', // 设置主机地址（可选）
    open: true, // 自动打开浏览器（可选）
    proxy: {
      '/client-service/chat/': {
        target: 'http://localhost', 
        changeOrigin: true
      },
      '/client-service/moment/': {
        target: 'http://localhost', 
        changeOrigin: true
      },
      '/connect-service/ws/': {
        target: 'ws://localhost',
        changeOrigin: true,
        ws: true
      },
      '/aigc-service/event/': {
        target: 'http://localhost',
        changeOrigin: true
      }
    }
  }
})