Fixes: with hariom help for running api in prod for swagger even in dev

This commit is contained in:
Agusti Fernandez Pardo committed 2022-04-30 23:07:21 +02:00
1 parent 167a42156d
commit a2d16800aa
4 files changed
+50 -41

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ export const httpMethod = (allowedHttpMethod: "GET" | "POST" | "PATCH" | "DELETE
// that checks if it's just a string or an array and apply the correct logic to both cases.
export const httpMethods = (allowedHttpMethod: string[]): NextMiddleware => {
return async function (req, res, next) {
if (allowedHttpMethod.map((method) => method === req.method)) {
if (allowedHttpMethod.some((method) => method === req.method || req.method == "OPTIONS")) {
await next();
} else {
res.status(405).json({ message: `Only ${allowedHttpMethod} Method allowed` });