Skip to content

Commit

Permalink
revert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadim Ritter committed Aug 23, 2024
1 parent 5bbe8ad commit aa21ca9
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,28 @@ import * as ENV from "./config/envConfig";
const app: Express = express();

const port: string = ENV.SERVER_PORT;
const viewPath: string = __dirname + "/views/";
const distPath: string = __dirname + "/dist/";
const path: string = __dirname + "/views/";

// Get environment mode for local dev and set CORS options
//get environment mode for local dev and set cors options
LOG.info("env mode: " + ENV.NODE_ENV);
if(ENV.NODE_ENV === "dev"){
app.use(cors(getCorstOptions()))
}

//server static files
app.use(express.static(viewPath));
app.use(ENV.BASE_PATH, express.static(distPath));

//parse incoming requests
app.use(express.static(path));
app.use(bodyParser.json());

//middleware and routes config
app.use(apiRequestLogger);

app.use(authorizationRoutes);
app.use(routes);

// Serve the index.html for the root path
app.get("/", (req: Request, res: Response) => {
res.sendFile(viewPath + "index.html");
});

// Serve the index.html for custom path
app.get(ENV.BASE_PATH + "/*", (req: Request, res: Response) => {
res.sendFile(distPath + "index.html");
app.get("/", (req: Request, res: Response) => {
res.sendFile(path + "index.html");
});

//fallback route, SPA routing
app.get("*", (req: Request, res: Response) => {
res.sendFile(viewPath + "index.html");
res.sendFile(path + "index.html");
});

app.listen(port, () => {
Expand Down

0 comments on commit aa21ca9

Please sign in to comment.