X Tutup
Skip to content

fix(api-server): add required 'alg' option to JWT middleware#4368

Open
AmriteshKhare wants to merge 1 commit intopear-devs:masterfrom
AmriteshKhare:fix/api-server-jwt-alg
Open

fix(api-server): add required 'alg' option to JWT middleware#4368
AmriteshKhare wants to merge 1 commit intopear-devs:masterfrom
AmriteshKhare:fix/api-server-jwt-alg

Conversation

@AmriteshKhare
Copy link

Problem

The api-server plugin's JWT middleware is missing the required alg option, which was introduced as a mandatory parameter in Hono v4.11.10. This causes all /api/* endpoints to return HTTP 500 Internal Server Error, completely breaking:

  • REST API endpoints (/api/v1/song, /api/v1/play, etc.)
  • WebSocket connections (/api/v1/ws)
  • Any third-party client relying on the api-server plugin

Error

Error: JWT auth middleware requires options for "alg"
    at jwt (hono/dist/middleware/jwt/jwt.js:12:11)
    at main.ts:101:22

Fix

Added alg: 'HS256' to the jwt() middleware options in src/plugins/api-server/backend/main.ts. This matches the algorithm used by the sign() function in the auth route (hono/jwt defaults to HS256).

Changes

  • src/plugins/api-server/backend/main.ts: Added alg: 'HS256' to JWT middleware config (1 line)

Testing

  • Verified the API server starts without errors
  • Confirmed /api/v1/song returns HTTP 200 with correct song data
  • Confirmed /auth/{id} authentication flow works end-to-end
  • WebSocket connections succeed on /api/v1/ws

Hono v4.11.10 changed the JWT middleware to require an explicit 'alg'
parameter. Without it, all /api/* endpoints return HTTP 500 Internal
Server Error, completely breaking the api-server plugin for any client
(e.g. remote control apps, WebSocket connections).

This adds alg: 'HS256' to match the algorithm used by the sign()
function in the auth route.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

X Tutup