Repository navigation
Use runtime direct gateway modifier (#1) - #199
Merged
Merged
Conversation
* Simplify direct gateway URL builder * Fix direct gateway base URL helper to use window.RUNTIME_CONFIG for modifier - Updated getDirectGatewayBaseUrl to read VITE_DIRECT_MCP_GATEWAY_MODIFIER from window.RUNTIME_CONFIG for
Contributor
Reviewer's GuideThis PR centralizes and configures the direct gateway URL logic by introducing a runtime-config-driven modifier. It replaces hardcoded port suffixes in the UI with a reusable helper that reads an env var, and propagates the new VITE_DIRECT_MCP_GATEWAY_MODIFIER through backend handlers, frontend initialization, and deployment templates. Sequence diagram for runtime config propagation of VITE_DIRECT_MCP_GATEWAY_MODIFIERsequenceDiagram
participant User
participant Frontend
participant Backend
participant ConfigStore
User->>Frontend: Loads app
Frontend->>Backend: GET /runtime-config
Backend->>ConfigStore: Read DirectMCPGatewayModifier
ConfigStore-->>Backend: Return value
Backend-->>Frontend: JSON { VITE_DIRECT_MCP_GATEWAY_MODIFIER: value }
Frontend->>Frontend: Store in window.RUNTIME_CONFIG
Frontend->>Frontend: Use getDirectGatewayBaseUrl() with modifier
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey @Divyanshubansaldb - I've reviewed your changes - here's some feedback:
- Extract getDirectGatewayBaseUrl into a standalone utility module to reduce component bloat and make it easier to unit test the URL-building logic.
- Consider using the native URL API (or URLPattern) instead of manual regex/substring operations to handle ports and paths more robustly when composing the gateway URL.
- Ensure that window.RUNTIME_CONFIG.VITE_DIRECT_MCP_GATEWAY_MODIFIER is loaded before rendering so you don’t accidentally fall back to the default port if the runtime config isn’t yet available.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Extract getDirectGatewayBaseUrl into a standalone utility module to reduce component bloat and make it easier to unit test the URL-building logic.
- Consider using the native URL API (or URLPattern) instead of manual regex/substring operations to handle ports and paths more robustly when composing the gateway URL.
- Ensure that window.RUNTIME_CONFIG.VITE_DIRECT_MCP_GATEWAY_MODIFIER is loaded before rendering so you don’t accidentally fall back to the default port if the runtime config isn’t yet available.
## Individual Comments
### Comment 1
<location> `web/src/pages/gateway/gateway-manager.tsx:104` </location>
<code_context>
+ modifier = '/' + modifier;
+ }
+
+ const originWithoutPort = origin.replace(/:\d+$/, '');
+ return `${originWithoutPort}${modifier}`.replace(/\/+$/, '');
+};
</code_context>
<issue_to_address>
Removing the port from origin may break for IPv6 addresses.
The current regex may not handle IPv6 addresses correctly. Use a URL parsing utility to reliably extract the host and port.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| modifier = '/' + modifier; | ||
| } | ||
|
|
||
| const originWithoutPort = origin.replace(/:\d+$/, ''); |
Contributor
There was a problem hiding this comment.
issue (bug_risk): Removing the port from origin may break for IPv6 addresses.
The current regex may not handle IPv6 addresses correctly. Use a URL parsing utility to reliably extract the host and port.
iFurySt
force-pushed
the
main
branch
3 times, most recently
from
July 16, 2025 06:35
a6483bd to
35748c4
Compare
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.
Simplify direct gateway URL builder
Fix direct gateway base URL helper to use window.RUNTIME_CONFIG for modifier
Summary by Sourcery
Introduce a runtime-configurable modifier for direct MCP gateway URLs by centralizing URL construction logic, exposing the new modifier in the API server’s runtime config, and updating environment types and deployment settings accordingly.
New Features:
Enhancements:
Deployment: