Reddirect 404erro only on dev

This commit is contained in:
SebClem 2024-07-12 14:31:24 +02:00
parent b671be0e6a
commit 39e2478a03
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50

View File

@ -21,9 +21,9 @@ app.use(
app.set("port", process.env.PORT || 3000);
app.use(
morgan("dev", { stream: { write: (message) => logger.debug(message) } })
);
// app.use(
// morgan("dev", { stream: { write: (message) => logger.debug(message) } })
// );
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
@ -35,13 +35,14 @@ app.use("/v2/api/", apiV2Router);
Error handler
----------------------------------------------------------
*/
// catch 404 and forward to error handler
app.use((req, res, next) => {
next(createError(404));
});
// error handler
if (process.env.NODE_ENV === "development") {
if (app.get("env") == "development") {
// catch 404 and forward to error handler
app.use((req, res, next) => {
next(createError(404));
});
// only use in development
app.use(errorHandler());
}