Skip to content

fix: use gateway-supplied MCP endpoint URL instead of window.location.origin - #107

Open
marekdano wants to merge 1 commit into
mainfrom
6632-virtual-server-endpoint-url
Open

fix: use gateway-supplied MCP endpoint URL instead of window.location.origin#107
marekdano wants to merge 1 commit into
mainfrom
6632-virtual-server-endpoint-url

Conversation

@marekdano

Copy link
Copy Markdown
Contributor

Fixes IBM/mcp-context-forge#6632

Depends on IBM/mcp-context-forge#6656 — please don't merge this before that backend PR lands. VirtualServer.url only exists in gateway responses once #6656 ships; until then this PR is a no-op and silently keeps today's window.location.origin fallback behavior.

Summary

Flagged in review on #101:

getVirtualServerEndpoint (src/components/gateways/utils.ts:21-27) still builds the virtual server's MCP endpoint as ${window.location.origin}/servers/{id}/mcp, the same assumption about who owns the origin that this PR removes from redirect_uri. The BFF proxies only /api/*, so that URL hits the SPA fallback and returns index.html with a 200.

Same class of bug as the OAuth redirect_uri fix in #101: the web UI's own origin isn't necessarily where the gateway serves its endpoints in a split deployment. IBM/mcp-context-forge#6656 adds a url field to ServerRead, computed server-side from the gateway's own APP_DOMAIN (the same base URL OAuth's redirect_uri default already uses). This PR switches the frontend to use it.

Changes

  • src/types/server.ts: add url?: string to VirtualServer.
  • src/components/gateways/utils.ts: getVirtualServerEndpoint now takes the server object and prefers server.url over constructing from window.location.origin, which remains only as a fallback for gateways older than the url field.
  • src/components/gateways/VirtualServerDetailsPanel.tsx: updated the one call site.
  • Tests: utils.test.ts covers the url-preferred path and both fallback cases.

….origin

Signed-off-by: Marek Dano <mk.dano@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][UI-REWRITE]: Virtual server MCP endpoint is built from the browser origin, so the copied URL serves the SPA

1 participant