garm/webapp/vite.config.ts
Gabriel Adrian Samfira eec158b32c Add SPA UI for GARM
This change adds a single page application front-end to GARM. It uses
a generated REST client, built from the swagger definitions, the websocket
interface for live updates of entities and eager loading of everything
except runners, as users may have many runners and we don't want to load
hundreds of runners in memory.

Proper pagination should be implemented in the API, in future commits,
to avoid loading lots of elements for no reason.

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
2025-08-16 09:09:13 +00:00

36 lines
1,022 B
TypeScript

import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig, loadEnv } from 'vite';
export default defineConfig(({ mode }) => {
// Load env variables based on the current mode
// Third param '' means load all variables, not just those prefixed with VITE_
const env = loadEnv(mode, process.cwd(), '');
console.log(env.VITE_GARM_API_URL);
return {
plugins: [sveltekit()],
server: {
proxy: {
// Proxy API calls to GARM backend
'/api': {
target: env.VITE_GARM_API_URL,
changeOrigin: true,
ws: true,
configure: (proxy, _options) => {
proxy.on('error', (err, _req, _res) => {
console.log('proxy error', err);
});
proxy.on('proxyReq', (proxyReq, req, _res) => {
console.log('Sending Request to the Target:', req.method, req.url);
});
proxy.on('proxyRes', (proxyRes, req, _res) => {
console.log('Received Response from the Target:', proxyRes.statusCode, req.url);
});
},
secure: false
}
}
}
};
});