mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
3ab9d196ab
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.
20 lines
476 B
TypeScript
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
|
|
}`,
|
|
);
|
|
});
|