refactor(server): changed to log only when in dev, and removed the redirect of the url
This commit is contained in:
@@ -39,7 +39,10 @@ createLog("info", "LST", "server", `Server is installed: ${installed}`);
|
||||
const app = new OpenAPIHono({ strict: false });
|
||||
|
||||
// middle ware
|
||||
app.use("*", logger());
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
app.use("*", logger());
|
||||
}
|
||||
|
||||
app.use(
|
||||
"*",
|
||||
cors({
|
||||
@@ -53,17 +56,17 @@ app.use(
|
||||
);
|
||||
|
||||
// Middleware to normalize route case
|
||||
app.use("*", async (c, next) => {
|
||||
const lowercasedUrl = c.req.url.toLowerCase();
|
||||
//console.log("Incoming Request:", c.req.url, c.req.method);
|
||||
// If the URL is already lowercase, continue as usual
|
||||
if (c.req.url === lowercasedUrl) {
|
||||
return next();
|
||||
}
|
||||
// app.use("*", async (c, next) => {
|
||||
// // const lowercasedUrl = c.req.url.toLowerCase();
|
||||
// console.log("Incoming Request:", c.req.url, c.req.method);
|
||||
// // // If the URL is already lowercase, continue as usual
|
||||
// // if (c.req.url === lowercasedUrl) {
|
||||
// await next();
|
||||
// // }
|
||||
|
||||
// Otherwise, re-route internally
|
||||
return c.redirect(lowercasedUrl, 308); // 308 preserves the HTTP method
|
||||
});
|
||||
// // // Otherwise, re-route internally
|
||||
// // return c.redirect(lowercasedUrl, 308); // 308 preserves the HTTP method
|
||||
// });
|
||||
|
||||
app.doc("/api/ref", {
|
||||
openapi: "3.0.0",
|
||||
|
||||
Reference in New Issue
Block a user