fix: include API key in CORS proxy requests for MCP connections#21358
Closed
satishkc7 wants to merge 2 commits into
Closed
fix: include API key in CORS proxy requests for MCP connections#21358satishkc7 wants to merge 2 commits into
satishkc7 wants to merge 2 commits into
Conversation
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.
Contributor
Author
|
Closing - this is a duplicate of #21193 which was already merged. |
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.
When a WebUI MCP server is configured with authentication headers and
useProxyis 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 sobuildProxiedHeadersis only called whenuseProxyis 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.