fix(firebase-auth): throw HTTPException for bad request (#194)

pull/195/head
Kei Kamikawa 2023-10-06 16:48:22 +09:00 committed by GitHub
parent 4eb3eb5e5a
commit 152e93e598
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/firebase-auth': patch
---
fixed to make HTTPException instead of reponse null for bad request

View File

@ -39,9 +39,10 @@ export const verifyFirebaseAuth = (userConfig: VerifyFirebaseAuthConfig): Middle
return async (c, next) => { return async (c, next) => {
const authorization = c.req.headers.get(config.AuthorizationHeaderKey) const authorization = c.req.headers.get(config.AuthorizationHeaderKey)
if (authorization === null) { if (authorization === null) {
return new Response(null, { const res = new Response('Bad Request', {
status: 400, status: 400,
}) })
throw new HTTPException(400, { res })
} }
const jwt = authorization.replace(/Bearer\s+/i, '') const jwt = authorization.replace(/Bearer\s+/i, '')
const auth = Auth.getOrInitialize( const auth = Auth.getOrInitialize(