Remove deprecated url.parse() usage from the custom server

Node flags legacy url.parse() (DEP0169) as having security implications
and recommends the WHATWG URL API instead. The main request handler's
parsedUrl argument to Next's handle() is optional and unused by us, so
that call is dropped entirely (matching Next's own minimal custom-server
example); the WS upgrade path-check now uses `new URL()` instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-15 19:41:37 +02:00
co-authored by Claude Sonnet 5
parent 466458a664
commit d3e3360d6e
+2 -3
View File
@@ -1,6 +1,5 @@
import "./src/bootstrap/async-local-storage-polyfill";
import { createServer } from "node:http";
import { parse } from "node:url";
import next from "next";
import { WebSocketServer } from "ws";
import { getConfig } from "./src/lib/config/load";
@@ -25,14 +24,14 @@ const handle = app.getRequestHandler();
app.prepare().then(() => {
const httpServer = createServer((req, res) => {
handle(req, res, parse(req.url ?? "/", true));
handle(req, res);
});
const wss = new WebSocketServer({ noServer: true });
attachWsServer(wss);
httpServer.on("upgrade", (req, socket, head) => {
const { pathname } = parse(req.url ?? "/");
const { pathname } = new URL(req.url ?? "/", "http://internal");
if (pathname !== "/ws/runs") {
socket.destroy();
return;