Compare commits
3
Commits
466458a664
...
20989987f6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20989987f6 | ||
|
|
9dc45f751a | ||
|
|
d3e3360d6e |
+6
-4
@@ -1,6 +1,5 @@
|
|||||||
import "./src/bootstrap/async-local-storage-polyfill";
|
import "./src/bootstrap/async-local-storage-polyfill";
|
||||||
import { createServer } from "node:http";
|
import { createServer } from "node:http";
|
||||||
import { parse } from "node:url";
|
|
||||||
import next from "next";
|
import next from "next";
|
||||||
import { WebSocketServer } from "ws";
|
import { WebSocketServer } from "ws";
|
||||||
import { getConfig } from "./src/lib/config/load";
|
import { getConfig } from "./src/lib/config/load";
|
||||||
@@ -24,17 +23,20 @@ const app = next({ dev, hostname, port });
|
|||||||
const handle = app.getRequestHandler();
|
const handle = app.getRequestHandler();
|
||||||
|
|
||||||
app.prepare().then(() => {
|
app.prepare().then(() => {
|
||||||
|
const nextUpgradeHandler = app.getUpgradeHandler();
|
||||||
|
|
||||||
const httpServer = createServer((req, res) => {
|
const httpServer = createServer((req, res) => {
|
||||||
handle(req, res, parse(req.url ?? "/", true));
|
handle(req, res);
|
||||||
});
|
});
|
||||||
|
|
||||||
const wss = new WebSocketServer({ noServer: true });
|
const wss = new WebSocketServer({ noServer: true });
|
||||||
attachWsServer(wss);
|
attachWsServer(wss);
|
||||||
|
|
||||||
httpServer.on("upgrade", (req, socket, head) => {
|
httpServer.on("upgrade", (req, socket, head) => {
|
||||||
const { pathname } = parse(req.url ?? "/");
|
const { pathname } = new URL(req.url ?? "/", "http://internal");
|
||||||
if (pathname !== "/ws/runs") {
|
if (pathname !== "/ws/runs") {
|
||||||
socket.destroy();
|
// Anything else (e.g. Next's own dev-mode HMR websocket at /_next/hmr) is Next's to handle.
|
||||||
|
nextUpgradeHandler(req, socket, head).catch(() => socket.destroy());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default function RootLayout({
|
|||||||
lang="en"
|
lang="en"
|
||||||
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
|
className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
|
||||||
>
|
>
|
||||||
<body className="bg-background text-foreground flex min-h-full flex-col">
|
<body className="bg-background text-foreground flex min-h-full flex-col" suppressHydrationWarning>
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
{children}
|
{children}
|
||||||
<Toaster />
|
<Toaster />
|
||||||
|
|||||||
Reference in New Issue
Block a user