Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BadRequestException leads 500 error #40

Open
mtsmfm opened this issue Sep 29, 2023 · 0 comments
Open

BadRequestException leads 500 error #40

mtsmfm opened this issue Sep 29, 2023 · 0 comments

Comments

@mtsmfm
Copy link

mtsmfm commented Sep 29, 2023

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: ["/(.*)"],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant