@@ -5,8 +5,8 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "NEXT_TELEMETRY_DISABLED=1 next dev -H 0.0.0.0",
|
"dev": "NEXT_TELEMETRY_DISABLED=1 next dev -H 0.0.0.0",
|
||||||
"build": "NEXT_TELEMETRY_DISABLED=1 next build --webpack",
|
"build": "NEXT_TELEMETRY_DISABLED=1 next build",
|
||||||
"start": "NEXT_TELEMETRY_DISABLED=1 NODE_ENV=production node server.mjs",
|
"start": "NEXT_TELEMETRY_DISABLED=1 next start -H 0.0.0.0",
|
||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
import { existsSync, statSync } from "node:fs";
|
|
||||||
import { createServer } from "node:http";
|
|
||||||
import path from "node:path";
|
|
||||||
import { fileURLToPath, parse } from "node:url";
|
|
||||||
|
|
||||||
import next from "next";
|
|
||||||
|
|
||||||
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
||||||
const port = Number.parseInt(process.env.PORT ?? "3910", 10);
|
|
||||||
const hostname = process.env.HOSTNAME ?? "0.0.0.0";
|
|
||||||
const dev = process.env.NODE_ENV !== "production";
|
|
||||||
|
|
||||||
const app = next({ dev, hostname, port });
|
|
||||||
const handle = app.getRequestHandler();
|
|
||||||
const nextStaticRoot = path.resolve(dirname, ".next/static");
|
|
||||||
|
|
||||||
function isMissingNextStaticAsset(pathname) {
|
|
||||||
if (!pathname.startsWith("/_next/static/")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let relativePath;
|
|
||||||
try {
|
|
||||||
relativePath = decodeURIComponent(pathname.replace("/_next/static/", ""));
|
|
||||||
} catch {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const assetPath = path.resolve(nextStaticRoot, relativePath);
|
|
||||||
if (!assetPath.startsWith(`${nextStaticRoot}${path.sep}`)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return !existsSync(assetPath) || !statSync(assetPath).isFile();
|
|
||||||
} catch {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await app.prepare();
|
|
||||||
|
|
||||||
createServer((req, res) => {
|
|
||||||
const parsedUrl = parse(req.url ?? "/", true);
|
|
||||||
const pathname = parsedUrl.pathname ?? "/";
|
|
||||||
|
|
||||||
if (isMissingNextStaticAsset(pathname)) {
|
|
||||||
res.statusCode = 404;
|
|
||||||
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
||||||
res.end("Not found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle(req, res, parsedUrl);
|
|
||||||
}).listen(port, hostname, () => {
|
|
||||||
console.log(`TicketTracker frontend listening on http://${hostname}:${port}`);
|
|
||||||
});
|
|
||||||
Reference in New Issue
Block a user