import { defineConfig } from '@vben/vite-config';

export default defineConfig(async () => {
  return {
    application: {},
    vite: {
      server: {
        proxy: {
          '/api': {
            changeOrigin: true,
            target: 'http://localhost:5211',
            ws: true,
          },
          '/file-api': {
            changeOrigin: true,
            target: 'http://localhost:8080',
            rewrite: (path) => path.replace(/^\/file-api/, ''),
          },
          '/im-api': {
            changeOrigin: true,
            target: 'http://localhost:5212',
            rewrite: (path) => path.replace(/^\/im-api/, '/api'),
            ws: true,
          },
          '/im-signalr': {
            changeOrigin: true,
            target: 'http://localhost:5212',
            rewrite: (path) => path.replace(/^\/im-signalr/, ''),
            ws: true,
          },
          '/workflow-api': {
            changeOrigin: true,
            target: 'http://localhost:5213',
            rewrite: (path) => path.replace(/^\/workflow-api/, ''),
          },
        },
      },
    },
  };
});
