mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-29 22:19:31 +02:00
Seperate servers
This commit is contained in:
parent
0af78ad64f
commit
eea8afd792
8 changed files with 214 additions and 189 deletions
29
server/nextServer.ts
Normal file
29
server/nextServer.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import next from "next";
|
||||
import express from "express";
|
||||
import { parse } from "url";
|
||||
import logger from "@server/logger";
|
||||
import config from "@server/config";
|
||||
|
||||
const nextPort = config.server.next_port;
|
||||
|
||||
export async function createNextServer() {
|
||||
// const app = next({ dev });
|
||||
const app = next({ dev: process.env.ENVIRONMENT !== "prod" });
|
||||
const handle = app.getRequestHandler();
|
||||
|
||||
await app.prepare();
|
||||
|
||||
const nextServer = express();
|
||||
|
||||
nextServer.all("*", (req, res) => {
|
||||
const parsedUrl = parse(req.url!, true);
|
||||
return handle(req, res, parsedUrl);
|
||||
});
|
||||
|
||||
nextServer.listen(nextPort, (err?: any) => {
|
||||
if (err) throw err;
|
||||
logger.info(`Next.js server is running on http://localhost:${nextPort}`);
|
||||
});
|
||||
|
||||
return nextServer;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue