Intermedio
19 agosto 2026

Trova il bug: Vue.js / Nuxt.js

Uno snippet di codice. Trova il bug, o dimostra che non ce n'è.

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})

Clicca sulle righe che causano il problema.

Il tuo verdetto

Un tentativo al giorno. La risposta appare subito dopo.

Mantieni la tua serie

Crea un account per conservare la tua serie e seguire i tuoi progressi.

Crea un account