We had developed a compact app that was working flawlessly, but then we were tasked with transforming it into something accessible for others in our organization to utilize... and that led to everything breaking down. Our initial setup included a simple express server with a few API routes along with a React application being served.
Originally, we accessed our app using a URL pattern similar to:
Our express server was listening to routes like:
// server.js:
import "./env";
import app from "app";
import { logger } from "@company/shared-code";
let fs = require("fs");
let https = require("https");
let privateKey = fs.readFileSync(`${process.env.CERT_HOME}/server.key`, "utf8");
let certificate = fs.readFileSync(`${process.env.CERT_HOME}/server.crt`, "utf8");
let credentials = { key: privateKey, cert: certificate };
let httpsServer = https.createServer(credentials, app);
httpsServer.listen(process.env.PORT || 3000, function () {
logger.info("Application listening on port " + (process.env.PORT || 3000) + "!");
});
// app.js:
import express from "express";
import health from "./routes/health/health.js";
const app = express();
app.use("/app_name/rest/health", health);
app.use(express.static(path.join(process.cwd(), "build")));
app.get("/app_name/ui*", function(req, res) {
res.sendFile(path.join(process.cwd(), "build", "index.html"));
});
// health.js:
import express from "express";
import os from "os";
import Promise from "bluebird";
const disk = Promise.promisifyAll(require("diskusage"));
const health = express.Router();
// Health route implementation
export default health;
In order to streamline providing proper certificates to new teams leveraging our app, we acquired a wildcard certificate covering *.technology.company.com/app_name/. This allowed the next team to fork the repository and deploy without acquiring additional certificates... which was beneficial.
We patted ourselves on the back for a successful deployment with the updated configuration. However, upon navigating to , every route seemed to be directed to get("/app_name/ui*")... despite numerous debugging attempts, I struggled to comprehend why my "rest" routes were not functioning as expected or reproduce this issue locally.
At present, when requesting , the response received is index.html and the health route is never triggered.
Has anyone encountered a similar issue?
UPDATE: provided supplementary details regarding the implementation