Skip to content

BadRequestException leads 500 error #40

@mtsmfm

Description

@mtsmfm

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

const currentUser = basicAuthentication(authHeader)
if (currentUser && compareCredentials(currentUser, credentialsObject)) {
return NextResponse.next()
}

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: ["/(.*)"],
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions