/// <reference types="vitest/config" />
import { defineConfig } from "@solidjs/start/config";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
  // Register our Nitro middleware that handles all /api/* paths.
  // Workaround for Vinxi 0.5.7 + @solidjs/start 1.3.2 build issue
  // where file-based API routes are not mounted as Nitro handlers.
  middleware: "./src/middleware.ts",
  vite: {
    plugins: [tailwindcss()],
    server: {
      proxy: {
        "/api/gateway": {
          target: "http://localhost:9100",
          changeOrigin: true,
          rewrite: (path: string) =>
            path
              .replace(/^\/api\/gateway\/api(\/|$)/, "/api$1")
              .replace(/^\/api\/gateway(\/|$)/, "/api$1"),
        },
        "/api/kb": {
          target: "http://localhost:9100",
          changeOrigin: true,
        },
      },
    },
  },
});
