Skip to content

fix: include API key in CORS proxy requests for MCP connections#21358

Closed
satishkc7 wants to merge 2 commits into
ggml-org:masterfrom
satishkc7:fix/webui-cors-proxy-api-key
Closed

fix: include API key in CORS proxy requests for MCP connections#21358
satishkc7 wants to merge 2 commits into
ggml-org:masterfrom
satishkc7:fix/webui-cors-proxy-api-key

Conversation

@satishkc7

Copy link
Copy Markdown
Contributor

When a WebUI MCP server is configured with authentication headers and useProxy is enabled, the CORS proxy requests were being sent without the API key. This caused 401 errors for protected MCP servers even when credentials were correctly configured.

The fix merges auth headers from getAuthHeaders() into the request before it goes through the proxy, so the API key is forwarded correctly. Also adjusts the conditional so buildProxiedHeaders is only called when useProxy is actually set, avoiding unnecessary header transformation for direct connections.

Tested against an MCP server behind API key auth with the CORS proxy enabled - requests now go through correctly.

When llama-server is started with --api-key-file and --webui-mcp-proxy,
the /cors-proxy endpoint requires authentication. The WebUI was not
including the Authorization header in proxy requests, causing MCP
connections to fail with 401.

Inject getAuthHeaders() into requestInit when useProxy is true so the
proxy request carries the Bearer token alongside the forwarded target
headers.

Fixes ggml-org#21167
Apply buildProxiedHeaders only when useProxy is true, pass headers
directly to the transport otherwise.
@satishkc7 satishkc7 requested a review from a team as a code owner April 3, 2026 07:00
@satishkc7

Copy link
Copy Markdown
Contributor Author

Closing - this is a duplicate of #21193 which was already merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant