// SPDX-License-Identifier: CPAL-1.0 // Copyright (c) 2026 Marek Novák. Part of Ianitor, under the Common Public Attribution // License 1.0: see LICENSE (its Exhibit A is this file's notice). 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, }, });