sv.js add as start script

This commit is contained in:
2025-02-07 08:47:19 +02:00
parent c6c34f0453
commit fa272c636c
2 changed files with 22 additions and 1 deletions

View File

@@ -11,7 +11,7 @@
"dev:debug": "cross-env NODE_OPTIONS='--inspect' next dev --turbopack --port 1976", "dev:debug": "cross-env NODE_OPTIONS='--inspect' next dev --turbopack --port 1976",
"build": "next build", "build": "next build",
"start:loc": "next start --port 1976", "start:loc": "next start --port 1976",
"start": "next start --hostname 127.1.4.78", "start": "NODE_ENV=production node sv.js",
"lint": "next lint", "lint": "next lint",
"tsql": "prisma generate --sql", "tsql": "prisma generate --sql",
"tsql:w": "prisma generate --sql --watch" "tsql:w": "prisma generate --sql --watch"

21
sv.js Normal file
View File

@@ -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
}`
);
});