mirror of
https://github.com/Gloridust/WechatOnCloud.git
synced 2026-09-20 03:23:32 +08:00
The /api/instances/:id/control/beat endpoint is a no-body POST used as a keep-alive heartbeat. The frontend sends it without a Content-Type header. Fastify's content-type parser is whitelist-based: any request whose Content-Type does not match a registered parser (including requests with no Content-Type at all) is rejected with 415 Unsupported Media Type. The panel already registered parsers for application/json (built-in) and application/octet-stream, but nothing for the missing-header case. Fix: register a '*' wildcard parser as a catch-all. Fastify resolves parsers with exact matches first, so the two existing parsers are unaffected; the wildcard only fires when nothing else matches. The beat handler ignores the body entirely, so returning null is correct. Verified: POST /control/beat without Content-Type now returns 403 (auth check passes the content-type layer) instead of 415; existing JSON and octet-stream routes continue to return 200 as before.