You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CORS headers missing on Fastify-level error responses (FST_ERR_BAD_URL et al) #376
When Fastify itself rejects a request before any handler runs (most commonly `FST_ERR_BAD_URL` for malformed percent-encoding like `%g1`, truncated `%E0%`, or invalid UTF-8 sequences), the 400 response carries no `Access-Control-Allow-*` headers. Browser clients then surface the response as a generic CORS / network error instead of the actual status code, which is confusing for debugging and undermines the per-handler CORS work in #371 / #374.
This isn't git-specific. The same shape applies to any route — Fastify's URL parser short-circuits before the handler-layer CORS hooks ever run. Possible fixes:
Global `onError` or `onSend` Fastify hook that decorates 4xx/5xx with the standard CORS headers when the request had an `Origin` header.
Use `@fastify/cors` plugin (would replace the per-handler CORS blocks across the codebase — bigger refactor but more consistent long-term).
Custom `schemaErrorFormatter` / `errorHandler` that injects CORS headers on the rejected response.
Activity
server: inject CORS headers on Fastify-internal errors (#376) (#421)