From fa272c636cb3510c99c1a47ef0f3f111c4641995 Mon Sep 17 00:00:00 2001 From: Yevhen Odynets Date: Fri, 7 Feb 2025 08:47:19 +0200 Subject: [PATCH] sv.js add as start script --- package.json | 2 +- sv.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 sv.js diff --git a/package.json b/package.json index 2cce2b1..00fb116 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "dev:debug": "cross-env NODE_OPTIONS='--inspect' next dev --turbopack --port 1976", "build": "next build", "start:loc": "next start --port 1976", - "start": "next start --hostname 127.1.4.78", + "start": "NODE_ENV=production node sv.js", "lint": "next lint", "tsql": "prisma generate --sql", "tsql:w": "prisma generate --sql --watch" diff --git a/sv.js b/sv.js new file mode 100644 index 0000000..798ca01 --- /dev/null +++ b/sv.js @@ -0,0 +1,21 @@ +const { createServer } = require('http'); +const { parse } = require('url'); +const next = require('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) => { + const parsedUrl = parse(req.url, true); + handle(req, res, parsedUrl); + }).listen(port, '127.1.4.78'); + + console.log( + `> Server listening at http://localhost:${port} as ${ + dev ? 'development' : process.env.NODE_ENV + }` + ); +}); \ No newline at end of file