openpanel/packages/devtools-server/src/serve-client.ts
Stefan Pejcic 8595a9f4e5 back
2024-05-08 19:58:53 +02:00

19 lines
502 B
TypeScript

import express from "express";
import path from "path";
import type { Express } from "express";
export const serveClient = (app: Express) => {
app.use(express.static(path.join(__dirname, "client")));
app.use((req, res, next) => {
if (req.path.startsWith("/api")) {
return next();
}
if (req.path.startsWith("/open-in-editor")) {
return next();
}
res.status(200).sendFile(path.join(__dirname + "/client/index.html"));
});
};