Skip to content

Commit

Permalink
fix: Prevent disk I/O each time GET * request hits server
Browse files Browse the repository at this point in the history
  • Loading branch information
am-ons committed Jun 20, 2024
1 parent f1ab6c5 commit 6cca8d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ export default function GetNodeServer(config: CustomConfig, blaiseApi: BlaiseApi
express.static(path.join(__dirname, `${buildFolder}/static`))
);

let indexFilePath = path.join(__dirname, `${buildFolder}/index.html`);
if (!fs.existsSync(indexFilePath)) {
indexFilePath = path.join(__dirname, `../public/index.html`);
}
server.get("*", function (_req: Request, res: Response) {
let filePath = path.join(__dirname, `${buildFolder}/index.html`);
if (!fs.existsSync(filePath)) {
filePath = path.join(__dirname, `../public/index.html`);
}
res.render(filePath);
res.render(indexFilePath);
});

server.use(function (err: Error, _req: Request, res: Response) {
Expand Down

0 comments on commit 6cca8d8

Please sign in to comment.