middleware icon indicating copy to clipboard operation
middleware copied to clipboard

@hono/clerk-auth empty response when JWT is expired

Open mariusbolik opened this issue 1 year ago • 1 comments

Hello,

I am using the @hono/clerk-auth package in my project. It works very well so far.

  • If a valid jwt is given, it responds with You are logged in!.
  • If no jwt is given, it responds with You are not logged in.
  • But if an expired jwt is given, it responds with an empty body. In this case I also want to respond with You are not logged in.

This is my code:

app.use('/payment/*', clerkMiddleware())

app.post('/payment/billing', (c) => {
  const auth = getAuth(c)

  console.log('auth', auth) 

  if (!auth?.userId) {
    return c.json({
      message: 'You are not logged in.',
    })
  }

  return c.json({
    message: 'You are logged in!',
    user: auth,
  })
})

Kind regards, Marius

mariusbolik avatar Apr 12 '24 10:04 mariusbolik

@mariusbolik the upgraded version of the middleware that uses Clerk Core v2 is now available. Could you please update and confirm the issue persists with the new version?

MonsterDeveloper avatar Apr 26 '24 17:04 MonsterDeveloper