import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";

export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), "");
  const backendOrigin = env.VITE_BACKEND_ORIGIN ?? "http://127.0.0.1:8080";

  return {
    plugins: [vue()],
    server: {
      port: 5175,
      proxy: {
        "/api": {
          target: backendOrigin,
          changeOrigin: true
        },
        "/ws": {
          target: backendOrigin,
          ws: true,
          changeOrigin: true
        }
      }
    }
  };
});
