import { readFileSync } from 'node:fs' import { fileURLToPath } from 'node:url' import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' const certDir = fileURLToPath(new URL('./certs/', import.meta.url)) // https://vite.dev/config/ export default defineConfig({ plugins: [ react(), tailwindcss(), ], server: { host: true, strictPort: true, https: { cert: readFileSync(`${certDir}localhost.pem`), key: readFileSync(`${certDir}localhost-key.pem`), }, proxy: { '/api': { target: 'http://localhost:8080', // Kein changeOrigin: so erhält das Backend den originalen Host // (z. B. localhost:5173), der zur Browser-Origin passt. Dadurch // akzeptiert der WebSocket-Origin-Check (coder/websocket) den Upgrade, // egal über welchen Host (localhost / LAN-IP) zugegriffen wird. ws: true, rewrite: (path) => path.replace(/^\/api/, ''), }, }, }, })