mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-06 05:48:00 +03:00
Merge pull request #218 from zkldi/zkldi/issue-214-If-reqbody-is-undefined-replace-it-with-an-empty-object
add a body neutraliser
This commit is contained in:
@@ -61,6 +61,14 @@ process.on("unhandledRejection", (reason, promise) => {
|
||||
// limit them so as not to choke the api
|
||||
app.use(express.json({ limit: "1mb" }));
|
||||
|
||||
app.use((req, res, next) => {
|
||||
if (req.method !== "GET" && !req.body) {
|
||||
req.body = {};
|
||||
}
|
||||
|
||||
return next();
|
||||
});
|
||||
|
||||
import mainRouter from "./router/router";
|
||||
|
||||
app.use("/", mainRouter);
|
||||
|
||||
Reference in New Issue
Block a user