Files
MOHAMMED WASIM KHAN 3ab9d196ab fix: remove deprecated url.parse() from custom-server example (#96105)
Fixes #86951

Removes the deprecated legacy `url.parse()` API (DEP0169) from the
custom-server example. The `parsedUrl` parameter is optional, so the
simplest fix is to remove the `parse()` call and pass only `(req, res)`
to the handler, matching the docs code block that was already updated in
#86986.
2026-07-24 00:04:08 +02:00

20 lines
476 B
TypeScript

import { createServer } from "http";
import next from "next";
const port = parseInt(process.env.PORT || "3000", 10);
const dev = process.env.NODE_ENV !== "production";
const app = next({ dev });
const handle = app.getRequestHandler();
app.prepare().then(() => {
createServer((req, res) => {
handle(req, res);
}).listen(port);
console.log(
`> Server listening at http://localhost:${port} as ${
dev ? "development" : process.env.NODE_ENV
}`,
);
});