fix(auth): scope well-known CORS to /.well-known/* only #285
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.63) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.63 · 278 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.337
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.063
Real PR Conversation Timeline
1 comments
"Review active on #285"
general
weight: 0.35
rozzilla
Problem
With
authorization.enabled,src/routes/well-known.tsregistered@fastify/cors(origin: true) inside afastify-pluginwrapper, so CORS applied to the whole app:Originwas reflected on the application's own routes;POST /mcpwere answered withGET, HEAD, OPTIONSonly and without theMcp-headers, so browsers blocked the request;@fastify/corsfailed to start withFST_ERR_DEC_ALREADY_PRESENT(corsPreflightEnabled).Fix
register, notfastify-plugin) together with a smallonRequestCORS hook and anOPTIONS /.well-known/route. CORS now covers/.well-known/only.@fastify/corsis no longer used there. Moving it into the child context was not enough: it callsdecorateRequest('corsPreflightEnabled'), which still clashes with an app-level registration (child contexts inherit the parent's decorators), and it adds anOPTIONSroute, which is global and would keep answering preflights for every path. It moves todevDependenciesbecause only the tests use it./mcpis left to the application. The README has a new CORS section with an@fastify/corsexample that allowsGET/POST/DELETEand theAuthorization/Mcp-headers, and exposesMcp-Session-Id.The auth preHandler still skips
/.well-known/(it matches on the URL, and the child context inherits the root hook).Tests
New tests in
test/well-known-routes.test.ts:Access-Control-Allow-Origin;@fastify/corsbefore the plugin (authorization enabled) starts, its CORS policy applies to/mcp, and the well-known metadata stays public with its own CORS.Breaking change
Apps that relied on the plugin's leaked CORS headers on their own routes, or on
/mcp, no longer get them and need to register@fastify/corsthemselves (see README).Fixes #258
🤖 Generated with Claude Code
https://claude.ai/code/session_01UF4S3w7iA83V9DVsasLJzM