Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: add custom server

nafees nazik2c011b7d53b6
diff --git a/backend/src/index.ts b/backend/src/index.ts
index 08b159d427..020c7a96c4 100644
--- a/backend/src/index.ts
+++ b/backend/src/index.ts
@@ -87,6 +87,10 @@ import { setup } from "./utils/setup";
import { syncSecretsToThirdPartyServices } from "./queues/integrations/syncSecretsToThirdPartyServices";
import { githubPushEventSecretScan } from "./queues/secret-scanning/githubScanPushEvent";
const SmeeClient = require("smee-client"); // eslint-disable-line
+import path from "path";
+import next from "next";
+
+const dir = path.join(__dirname, "../../frontend");
const main = async () => {
await setup();
@@ -209,6 +213,19 @@ const main = async () => {
// server status
app.use("/api", healthCheck);
+ if (process.env.NODE_ENV === "production") {
+ const nextApp = next({
+ dev: false,
+ dir
+ });
+ const nextHandler = nextApp.getRequestHandler();
+ await nextApp.prepare();
+
+ app.all("*", (req, res) => {
+ return nextHandler(req, res);
+ });
+ }
+
//* Handle unrouted requests and respond with proper error message as well as status code
app.use((req, res, next) => {
if (res.headersSent) return next();