-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.prod.js
38 lines (30 loc) · 1.06 KB
/
index.prod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// This file gets manually copied into build/ as part of deployment. Doing it
// this way avoids a ton of weird compat hacks with react-router v7.
import "dotenv/config";
import express from "express";
// This only exists after a production build, when this file is copied into Docker
import { app as rrApp } from "./build/server/index.js";
const app = express();
console.log("Starting production webserver");
app.use(rrApp);
app.use(
"/assets",
express.static("build/client/assets", { immutable: true, maxAge: "1y" }),
);
app.use(express.static("build/client", { maxAge: "1h" }));
/** ERROR TRACKING
Must go after route handlers
*/
const errorHandler = (error) => {
if (error instanceof Error) {
console.log("ERROR", error.message, error.stack);
} else if (typeof error === "string") {
console.log("ERROR", error);
}
};
process.on("uncaughtException", errorHandler);
process.on("unhandledRejection", errorHandler);
const PORT = process.env.PORT || "3000";
app.listen(PORT, "0.0.0.0", async () => {
console.log("INI", "Now listening on port", PORT);
});