2026-09-06 14:09:17 +00:00
|
|
|
import { readFileSync } from "node:fs";
|
2026-09-03 16:16:34 +00:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import react from "@vitejs/plugin-react";
|
2026-09-12 09:36:36 +00:00
|
|
|
|
|
|
|
|
function proxyToApi() {
|
|
|
|
|
return {
|
|
|
|
|
target: "http://127.0.0.1:3101",
|
|
|
|
|
ws: true,
|
|
|
|
|
configure(proxy: { on: (event: string, listener: (req: { getHeader: (name: string) => unknown; setHeader: (name: string, value: string) => void; removeHeader: (name: string) => void }) => void) => void }) {
|
|
|
|
|
proxy.on("proxyReq", (proxyReq) => {
|
|
|
|
|
const host = proxyReq.getHeader("host");
|
|
|
|
|
if (typeof host === "string" && host) proxyReq.setHeader("origin", `http://${host}`);
|
|
|
|
|
proxyReq.removeHeader("sec-fetch-site");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
{
|
|
|
|
|
name: "desktop-viewer",
|
|
|
|
|
generateBundle() {
|
|
|
|
|
this.emitFile({
|
|
|
|
|
type: "asset",
|
|
|
|
|
fileName: "vnc.html",
|
|
|
|
|
source: readFileSync(new URL("./vnc.html", import.meta.url), "utf8"),
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
build: { outDir: "dist", emptyOutDir: true },
|
|
|
|
|
server: {
|
|
|
|
|
host: true,
|
|
|
|
|
port: 5173,
|
|
|
|
|
strictPort: true,
|
|
|
|
|
proxy: { "/api": proxyToApi(), "/view": proxyToApi() },
|
|
|
|
|
},
|
|
|
|
|
});
|