Spaces:
Running
Running
File size: 1,593 Bytes
794cf6c ec75a88 794cf6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import { vibegame, consoleForwarding } from "vibegame/vite";
import { WebSocketServer } from "ws";
import { wsManager } from "./src/lib/server/api";
export default defineConfig({
plugins: [
svelte(),
vibegame(),
consoleForwarding(),
{
name: "websocket-server",
configureServer(server) {
const wss = new WebSocketServer({ noServer: true });
server.httpServer?.on("upgrade", (request, socket, head) => {
if (request.url === "/ws") {
wss.handleUpgrade(request, socket, head, (ws) => {
wsManager.handleConnection(ws, request);
});
}
});
server.middlewares.use((req, res, next) => {
if (req.url === "/auth/callback") {
res.statusCode = 200;
res.setHeader("Content-Type", "text/html");
res.end(`<!DOCTYPE html>
<html>
<head>
<title>Authenticating...</title>
<script type="module">
// Redirect to main app - the OAuth handler will process the URL params
window.location.href = '/';
</script>
</head>
<body>
<p>Authenticating...</p>
</body>
</html>`);
return;
}
next();
});
},
},
],
optimizeDeps: {
include: ["monaco-editor"],
},
server: {
host: "0.0.0.0",
port: parseInt(process.env.PORT || "7860"),
open: false,
strictPort: true,
allowedHosts: ["localhost", ".hf.space"],
},
build: {
target: "esnext",
sourcemap: true,
},
});
|