diff --git a/src/server/auth/login.ts b/src/server/auth/login.ts index 467994f..97606cb 100644 --- a/src/server/auth/login.ts +++ b/src/server/auth/login.ts @@ -78,4 +78,18 @@ app.get('/exchange', async (c) => { } }); +/** GET /api/auth/me — 查看当前用户信息(调试用) */ +app.get('/me', async (c) => { + const authHeader = c.req.header('Authorization'); + if (!authHeader?.startsWith('Bearer ')) { + return c.json({ error: 'No token' }, 401); + } + try { + const payload = jwt.verify(authHeader.slice(7), JWT_SECRET) as JwtPayload; + return c.json(payload); + } catch { + return c.json({ error: 'Invalid token' }, 401); + } +}); + export default app;