36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/**
|
|
* Custom Next.js server. Standalone output mode can't be combined with a
|
|
* custom server (see next.config.ts), so production runs this file directly.
|
|
* LiveKit handles signaling and media separately; this process only serves
|
|
* the website and its API.
|
|
*/
|
|
import { createServer } from "node:http";
|
|
import next from "next";
|
|
|
|
const port = parseInt(process.env.PORT || "3000", 10);
|
|
const hostname = process.env.HOSTNAME || "0.0.0.0";
|
|
const dev = process.env.NODE_ENV !== "production";
|
|
|
|
const app = next({ dev, hostname, port });
|
|
|
|
app.prepare().then(() => {
|
|
// Must be requested after prepare() resolves.
|
|
const handle = app.getRequestHandler();
|
|
const upgradeHandle = app.getUpgradeHandler();
|
|
|
|
const server = createServer((req, res) => {
|
|
handle(req, res);
|
|
});
|
|
|
|
server.on("upgrade", (req, socket, head) => {
|
|
// Let Next.js handle its own upgrade requests (e.g. dev-mode HMR).
|
|
upgradeHandle(req, socket, head);
|
|
});
|
|
|
|
server.listen(port, () => {
|
|
console.log(
|
|
`> ANOUMA server listening at http://${hostname}:${port} (${dev ? "development" : "production"})`,
|
|
);
|
|
});
|
|
});
|