fix: compare providerHost against stripped protocol hostname in getWebsocketHost#1397
fix: compare providerHost against stripped protocol hostname in getWebsocketHost#1397leecalcote merged 2 commits intomasterfrom
Conversation
…bsocketHost Signed-off-by: Yi Nuo <218099172+yi-nuo426@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adjusts getWebsocketHost to correctly detect the Meshery Cloud production provider host when the input host has been parsed from a URL (and therefore does not include the protocol).
Changes:
- Derive the production host via
new URL(MESHERY_CLOUD_PROD).hostand compareproviderHostagainst that value. - Add an explanatory comment about protocol stripping during URL parsing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Compare against hostnames without protocol since parsedUrl.host | ||
| // strips the protocol (e.g. "cloud.layer5.io" not "https://cloud.layer5.io") | ||
| const prodHost = new URL(MESHERY_CLOUD_PROD).host; | ||
| if (providerHost === prodHost) { | ||
| return MESHERY_CLOUD_WS_PROD; | ||
| } else if (providerHost === MESHERY_CLOUD_STAGING) { | ||
| return MESHERY_CLOUD_WS_STAGING; |
There was a problem hiding this comment.
providerHost is passed as parsedUrl.host, which includes any explicit port (e.g. cloud.layer5.io:443). new URL(MESHERY_CLOUD_PROD).host will be cloud.layer5.io (no port), so this comparison will fail if the provider URL includes a port. Consider normalizing both sides using .hostname (or otherwise stripping any port / lowercasing) and doing the same normalization for staging for consistency.
Notes for Reviewers
This PR fixes #
Signed commits