Title: CORS headers missing on Fastify-level error responses (FST_ERR_BAD_URL et al) · Issue #376 · JavaScriptSolidServer/JavaScriptSolidServer · GitHub
Open Graph Title: CORS headers missing on Fastify-level error responses (FST_ERR_BAD_URL et al) · Issue #376 · JavaScriptSolidServer/JavaScriptSolidServer
X Title: CORS headers missing on Fastify-level error responses (FST_ERR_BAD_URL et al) · Issue #376 · JavaScriptSolidServer/JavaScriptSolidServer
Description: Surfaced during PR #374 review. When Fastify itself rejects a request before any handler runs (most commonly `FST_ERR_BAD_URL` for malformed percent-encoding like `%g1`, truncated `�%`, or invalid UTF-8 sequences), the 400 response car...
Open Graph Description: Surfaced during PR #374 review. When Fastify itself rejects a request before any handler runs (most commonly `FST_ERR_BAD_URL` for malformed percent-encoding like `%g1`, truncated `�%`, or invali...
X Description: Surfaced during PR #374 review. When Fastify itself rejects a request before any handler runs (most commonly `FST_ERR_BAD_URL` for malformed percent-encoding like `%g1`, truncated `�%`, or invali...
Opengraph URL: https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/376
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CORS headers missing on Fastify-level error responses (FST_ERR_BAD_URL et al)","articleBody":"Surfaced during PR #374 review.\n\nWhen 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.\n\n## Reproduction\n\n\\`\\`\\`bash\ncurl -i -H 'Origin: https://example.com' \\\n 'https://melvin.me/melvin/public/git/test-repo.git/info/refs%g1?service=git-upload-pack'\n\\`\\`\\`\n\n\\`\\`\\`\nHTTP/2 400\ncontent-type: application/json\ncontent-length: 155\n# (no access-control-* headers)\n\n{\"error\":\"Bad Request\",\"code\":\"FST_ERR_BAD_URL\", ...}\n\\`\\`\\`\n\n## Scope\n\nThis 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:\n\n1. Global \\`onError\\` or \\`onSend\\` Fastify hook that decorates 4xx/5xx with the standard CORS headers when the request had an \\`Origin\\` header.\n2. Use \\`@fastify/cors\\` plugin (would replace the per-handler CORS blocks across the codebase — bigger refactor but more consistent long-term).\n3. Custom \\`schemaErrorFormatter\\` / \\`errorHandler\\` that injects CORS headers on the rejected response.\n\n## Refs\n\n- #371 — \\`Git-Protocol\\` allowed in CORS preflight\n- #374 — \\`GIT_CORS_HEADERS\\` const + 4xx return paths in git handler\n- Copilot review thread on #374 line 119 (the comment that prompted this)","author":{"url":"https://github.com/melvincarvalho","@type":"Person","name":"melvincarvalho"},"datePublished":"2026-05-08T01:54:55Z","url":"https://github.com/JavaScriptSolidServer/JavaScriptSolidServer/issues/376"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4b83bc97-5ee8-2091-498a-d464f890c8ad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EC10:102FBB:77375A:971FE0:6B0398CB |
| html-safe-nonce | 4a68bb3a24acbbdfc658ea099fd80af134558d68961c83db33e1a1df8bb4a932 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzEwOjEwMkZCQjo3NzM3NUE6OTcxRkUwOjZCMDM5OENCIiwidmlzaXRvcl9pZCI6IjQ1ODc2MDUyMjA5MjU4NzIzMzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c95efe1c4384f42525acbc70eb17ae016c7f01117c5d4f18ef308895232e90a0 |
| hovercard-subject-tag | issue:4403200145 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/JavaScriptSolidServer/JavaScriptSolidServer/376/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e6f2addcbc26793b4570ae6f51a7f6f23c8f2c0bc80b88649a562788b6c621a1/JavaScriptSolidServer/JavaScriptSolidServer/issues/376 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e6f2addcbc26793b4570ae6f51a7f6f23c8f2c0bc80b88649a562788b6c621a1/JavaScriptSolidServer/JavaScriptSolidServer/issues/376 |
| og:image:alt | Surfaced during PR #374 review. When Fastify itself rejects a request before any handler runs (most commonly `FST_ERR_BAD_URL` for malformed percent-encoding like `%g1`, truncated `�%`, or invali... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | melvincarvalho |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/JavaScriptSolidServer/JavaScriptSolidServer git https://github.com/JavaScriptSolidServer/JavaScriptSolidServer.git |
| octolytics-dimension-user_id | 205442424 |
| octolytics-dimension-user_login | JavaScriptSolidServer |
| octolytics-dimension-repository_id | 958025407 |
| octolytics-dimension-repository_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 958025407 |
| octolytics-dimension-repository_network_root_nwo | JavaScriptSolidServer/JavaScriptSolidServer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width