// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. import { svelte } from "@sveltejs/vite-plugin-svelte"; import { defineConfig } from "vitest/config"; // Dev server: 127.0.0.1 only (CLAUDE.md), never --host 0.0.0.0. /api goes to control's --dev on // 127.0.0.1:7878. In production edge sends Authelia's identity and the per-boot proof; in dev // there is no Authelia, so the dev proxy (never the browser) adds the dev API token from // $IANITOR_DEV_TOKEN, which `ianitor-control --dev` prints. const control = process.env.IANITOR_CONTROL ?? "http://127.0.0.1:7878"; const token = process.env.IANITOR_DEV_TOKEN; export default defineConfig({ plugins: [svelte()], server: { host: "127.0.0.1", port: 5173, strictPort: true, proxy: { "/api": { target: control, changeOrigin: true, headers: token ? { Authorization: `Bearer ${token}` } : {}, }, }, }, preview: { host: "127.0.0.1" }, build: { outDir: "dist", sourcemap: false, assetsInlineLimit: 0 }, resolve: process.env.VITEST ? { conditions: ["browser"] } : undefined, test: { environment: "jsdom", setupFiles: ["./tests/setup.ts"], include: ["tests/**/*.test.ts"], testTimeout: 20000, }, });