nextjs-basic-auth-middleware icon indicating copy to clipboard operation
nextjs-basic-auth-middleware copied to clipboard

BadRequestException leads 500 error

Open mtsmfm opened this issue 2 years ago • 0 comments

Thank you for providing awesome package. I've noticed this middleware returns 500 if basicAuthentication throws BadRequestException

https://github.com/labd/nextjs-basic-auth-middleware/blob/db07837769d1795c1eac5bdcbccd7715b71f54df/src/middleware.ts#L52-L56

Is it intentional?

Actual

$ curl localhost:3000 -H 'authorization: foo' -I
HTTP/1.1 500 Internal Server Error

Expectation

$ curl localhost:3000 -H 'authorization: foo' -I
HTTP/1.1 400 Bad Request

middleware.ts

import { createNextAuthMiddleware } from "nextjs-basic-auth-middleware";

export const middleware = createNextAuthMiddleware({
  users: [{ name: "foo", password: "bar" }],
});
export const config = {
  matcher: ["/(.*)"],
};

mtsmfm avatar Sep 29 '23 02:09 mtsmfm