import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';

export default defineConfig({
	plugins: [sveltekit()],
	server: {
		proxy: {
			'/api': {
				target: process.env.BACKEND_URL || 'http://127.0.0.1:8000',
				changeOrigin: true,
				secure: false,
				rewrite: (path) => path.replace(/^\/api/, '/api')
			},
			'/ws': {
				target: (process.env.BACKEND_URL || 'http://127.0.0.1:8000').replace(/^http/, 'ws'),
				ws: true,
				changeOrigin: true,
				secure: false
			}
		}
	}
});
