import tailwindcss from '@tailwindcss/vite'; import { fileURLToPath } from 'node:url'; import { defineConfig, loadEnv } from 'vite'; import solid from 'vite-plugin-solid'; // The dev server proxies /api and the WebSocket at /ws to the backend: // job-search serve at its default address, or API_PROXY_TARGET if it's set. // /ws keeps the browser's Host header (changeOrigin: false), as the backend // only accepts a WebSocket whose Origin matches the host it was asked for. export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ''); const target = env.API_PROXY_TARGET || 'http://localhost:9393'; return { plugins: [solid(), tailwindcss()], // @/ is src/, matching "paths" in tsconfig.app.json. resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) }, }, server: { proxy: { '/api': { target, changeOrigin: true }, '/ws': { target, ws: true, changeOrigin: false }, }, }, }; });