mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-03 03:56:18 -04:00
[Status Page] SSR
This commit is contained in:
parent
ffb7ba176c
commit
c095767f4a
6 changed files with 92 additions and 29 deletions
|
@ -29,6 +29,12 @@ class UptimeKumaServer {
|
|||
httpServer = undefined;
|
||||
io = undefined;
|
||||
|
||||
/**
|
||||
* Cache Index HTML
|
||||
* @type {string}
|
||||
*/
|
||||
indexHTML = "";
|
||||
|
||||
static getInstance(args) {
|
||||
if (UptimeKumaServer.instance == null) {
|
||||
UptimeKumaServer.instance = new UptimeKumaServer(args);
|
||||
|
@ -55,6 +61,16 @@ class UptimeKumaServer {
|
|||
this.httpServer = http.createServer(this.app);
|
||||
}
|
||||
|
||||
try {
|
||||
this.indexHTML = fs.readFileSync("./dist/index.html").toString();
|
||||
} catch (e) {
|
||||
// "dist/index.html" is not necessary for development
|
||||
if (process.env.NODE_ENV !== "development") {
|
||||
log.error("server", "Error: Cannot find 'dist/index.html', did you install correctly?");
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
this.io = new Server(this.httpServer);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue