Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use consistent root for serving admin #588

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading