Skip to content

Commit

Permalink
Use consistent root for serving admin
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarnutsch committed Dec 4, 2024
1 parent 5bf5820 commit b025273
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions admin/server/server.js → admin/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const express = require("express");
const compression = require("compression");
const helmet = require("helmet");
const fs = require("fs");
const path = require("path");

const app = express();
const port = process.env.APP_PORT ?? 3000;

// Read index.html file
let indexFile = fs.readFileSync("../build/index.html", "utf8");
let indexFile = fs.readFileSync(path.join(__dirname, "../build/index.html"), "utf8");

// Replace environment variables
indexFile = indexFile.replace(/\$([A-Z_]+)/g, (match, p1) => {
Expand Down Expand Up @@ -42,7 +42,7 @@ app.get("/status/health", (req, res) => {
});

app.use(
express.static("../build", {
express.static(path.join(__dirname, "../build"), {
index: false, // Don't send index.html for requests to "/" as it will be handled by the fallback route (with replaced environment variables)
setHeaders: (res, path, stat) => {
if (path.endsWith(".js")) {
Expand Down
2 changes: 1 addition & 1 deletion admin/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "server",
"private": true,
"scripts": {
"serve": "node server.js"
"serve": "node index.js"
},
"dependencies": {
"compression": "^1.7.5",
Expand Down

0 comments on commit b025273

Please sign in to comment.