This repository has been archived on 2024-08-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
khufu/server/index.js

22 lines
828 B
JavaScript
Raw Permalink Normal View History

2021-08-06 19:56:59 -06:00
const express = require("express");
2021-08-23 20:06:27 -06:00
const { createProxyMiddleware: proxy } = require("http-proxy-middleware");
2021-11-06 20:11:52 -06:00
const port = process.env.KHUFU_DEV_PORT ?? 52002;
const { REACT_APP_CAIRO_URL, REACT_APP_NUBIAN_URL } = process.env;
const cairoProxyOpt = {
target: REACT_APP_CAIRO_URL,
changeOrigin: true,
pathRewrite: { "^/api/cairo": "/api" },
};
const nubianProxyOpt = {
target: REACT_APP_NUBIAN_URL,
changeOrigin: true,
pathRewrite: { "^/api/nubian": "/api" },
};
2021-08-06 19:56:59 -06:00
const app = express();
app.use("/", express.static("build"));
2021-11-06 20:11:52 -06:00
app.use("/api/cairo", proxy(cairoProxyOpt));
app.use("/api/nubian", proxy(nubianProxyOpt));
app.get("/healthcheck", (req, res) => res.sendStatus(200));
app.get("/alive", (req, res) => res.sendStatus(200));
app.listen(port, () => console.log(`🌴 Nile px server started on ${port}! 🌴`));