Mid-Level
August 19, 2026

Spot the bug: Vue.js / Nuxt.js

One snippet. Find the bug, or prove there isn't one.

typescript
1import jwt from 'jsonwebtoken'
2
3export default defineEventHandler(async (event) => {
4  const { refreshToken } = await readBody(event)
5
6  const decoded = jwt.verify(refreshToken, process.env.REFRESH_SECRET!) as { userId: string; iat: number }
7
8  if (Date.now() - decoded.iat * 1000 > 2592000000) {
9    throw createError({ statusCode: 401, message: 'Refresh token expired' })
10  }
11
12  const newToken = jwt.sign(
13    { userId: decoded.userId },
14    process.env.JWT_SECRET!,
15    { expiresIn: 3600 }
16  )
17
18  return { token: newToken }
19})

Click the lines that carry the problem.

Your verdict

One attempt per day. The answer shows up right after.

Keep your streak

Create an account to keep your streak and track your progress.

Create an account