Skip to content

Commit

Permalink
new approach
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadim Ritter committed Aug 28, 2024
1 parent 170f4d3 commit c0197cd
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,21 @@ if (ENV.NODE_ENV === "dev") {
app.use(apiRequestLogger);

// Static files config with dynamic base path
const basePath = ENV.BASE_PATH || "/";
app.use(basePath, express.static(path));
app.use(ENV.BASE_PATH, express.static(path));
app.use(bodyParser.json());

// API routes
app.use(basePath, authorizationRoutes);
app.use(basePath, routes);
app.use(authorizationRoutes);
app.use(routes);

// Static files route with dynamic base path
app.get(basePath + "/", (req: Request, res: Response) => {
app.get(ENV.BASE_PATH + "/", (req: Request, res: Response) => {
console.log("Serving main index at:", mainIndexPath);
res.sendFile(mainIndexPath);
});

// Catch-all route to handle all other requests
app.get(basePath + "/*", (req: Request, res: Response) => {
app.get(ENV.BASE_PATH + "/*", (req: Request, res: Response) => {
console.log("Catch-all route, serving main index at:", mainIndexPath);
res.sendFile(mainIndexPath);
});
Expand Down

0 comments on commit c0197cd

Please sign in to comment.