fix: inject X-Fusion-Route header + separate gateway/MLX API key layers (#52) - #53
Merged
Merged
Conversation
…rs (#52) D1 P0: 本地推理全量 401/403。fusion-mlx route_guard (#343/#349) Phase 2 默认 enforce,缺失 X-Fusion-Route 头的请求被 403 拒绝;且 fusion-code 把 MLX 层 key (FUSION_MLX_API_KEY) 当 Bearer 发给 gateway 层,gateway 有独立 key 体系 → 401。 修复: - getMlxAuthHeaders() 统一注入 X-Fusion-Route 头 (默认 local,可经 FUSION_ROUTE_HEADER 覆盖),覆盖全部 8 处请求点。 - 新增 isGatewayBaseUrl() + getGatewayApiKey():经 gateway (11432) 时用 FUSION_GATEWAY_API_KEY,直连 MLX (11434) 时用 FUSION_MLX_API_KEY。 - checkFusionMlxHealth() 区分 401 (鉴权失败) / 403 (route 头缺失), 输出明确诊断引导 (兼修 D2)。 - mlxFetchWithRetry() 401/403 不再静默,输出层级与 key 检查提示。 验证: - gateway 路径 (X-Fusion-Route: local + Bearer fg-demo-key-change-me) → available:true - MLX 直连路径 (X-Fusion-Route: local + Bearer dahai168) → 返回 55 模型 - tsc 0 error / 320 单元测试 pass / 无新增 lint Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复 D1 P0 阻断缺陷 — 本地推理全量 401/403
Closes #52
根因 (均在 fusion-code 侧)
X-Fusion-Route头: fusion-mlx route_guard (#343/#349) Phase 2 默认 enforce,缺失该头 → 403。FUSION_MLX_API_KEY) 当 Bearer 发给 gateway 层;gateway 有独立 key 体系 → 401。修复
getMlxAuthHeaders()统一注入X-Fusion-Route头 (默认local,可经FUSION_ROUTE_HEADER覆盖),覆盖全部 8 处请求点。isGatewayBaseUrl()+getGatewayApiKey():经 gateway (11432) 时用FUSION_GATEWAY_API_KEY,直连 MLX (11434) 时用FUSION_MLX_API_KEY。checkFusionMlxHealth()区分 401/403 并输出诊断引导 (兼修 D2)。mlxFetchWithRetry()401/403 不再静默。实测验证
X-Fusion-Route: local+Bearer fg-demo-key-change-meX-Fusion-Route: local+Bearer dahai168回归
配置提示
用户经 gateway 时须设
FUSION_GATEWAY_API_KEY为 gateway config 的 key,而非FUSION_MLX_API_KEY。🤖 Generated with Claude Code