Skip to content

Commit dfdfd9c

Browse files
author
Lasim
committed
feat(gateway): mask internal backend URL in command outputs for improved user experience
1 parent d676c9a commit dfdfd9c

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

services/gateway/src/commands/mcp.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TableFormatter } from '../utils/table';
1010
import { AuthenticationError } from '../types/auth';
1111
import { RefreshService } from '../services/refresh-service';
1212
import { ConfigurationChangeService } from '../services/configuration-change-service';
13+
import { displayBackendUrl } from '../utils/display';
1314

1415
// PID file location
1516
const PID_FILE = path.join(os.tmpdir(), 'deploystack-gateway.pid');
@@ -222,7 +223,7 @@ export function registerMCPCommand(program: Command) {
222223

223224
console.log(chalk.blue(`🤖 MCP Configuration Status`));
224225
console.log(chalk.gray(`🎯 Current team: ${chalk.cyan(credentials.selectedTeam.name)}`));
225-
console.log(chalk.gray(` Backend: ${backendUrl}\n`));
226+
console.log(chalk.gray(` Backend: ${displayBackendUrl(backendUrl)}\n`));
226227

227228
spinner = ora('Checking MCP configuration...').start();
228229

services/gateway/src/commands/teams.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { MCPConfigService } from '../core/mcp';
66
import { TableFormatter } from '../utils/table';
77
import { ToolDiscoveryManager } from '../utils/tool-discovery-manager';
88
import { AuthenticationError } from '../types/auth';
9+
import { displayBackendUrl } from '../utils/display';
910

1011
export function registerTeamsCommand(program: Command) {
1112
program
@@ -71,23 +72,23 @@ export function registerTeamsCommand(program: Command) {
7172
continueOnError: true
7273
});
7374

74-
console.log(chalk.gray(`🌐 Using backend: ${backendUrl}`));
75+
console.log(chalk.gray(`🌐 Using backend: ${displayBackendUrl(backendUrl)}`));
7576
} catch (mcpError) {
7677
// Team switch succeeded but MCP config failed - still show success but warn about MCP
7778
console.log(chalk.green(`✅ Switched to team: ${chalk.cyan(teamToSwitch.name)} (#${teamNumber})`));
7879
console.log(chalk.yellow('⚠️ Could not download MCP configurations for new team'));
7980
if (mcpError instanceof Error) {
8081
console.log(chalk.gray(` MCP Error: ${mcpError.message}`));
8182
}
82-
console.log(chalk.gray(`🌐 Using backend: ${backendUrl}`));
83+
console.log(chalk.gray(`🌐 Using backend: ${displayBackendUrl(backendUrl)}`));
8384
}
8485
return;
8586
}
8687

8788
if (teams.length === 0) {
8889
console.log(chalk.yellow('📭 You are not a member of any teams'));
8990
console.log(chalk.gray('💡 Contact your administrator to be added to a team'));
90-
console.log(chalk.gray(`🌐 Using backend: ${backendUrl}`));
91+
console.log(chalk.gray(`🌐 Using backend: ${displayBackendUrl(backendUrl)}`));
9192
return;
9293
}
9394

@@ -101,7 +102,7 @@ export function registerTeamsCommand(program: Command) {
101102
console.log(chalk.yellow('⚠️ No team selected - use --switch <team-number> to select one'));
102103
}
103104

104-
console.log(chalk.gray(`🌐 Using backend: ${backendUrl}\n`));
105+
console.log(chalk.gray(`🌐 Using backend: ${displayBackendUrl(backendUrl)}\n`));
105106

106107
// Create table
107108
const table = TableFormatter.createTable({

services/gateway/src/commands/whoami.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { DeployStackAPI } from '../core/auth/api-client';
55
import { TableFormatter } from '../utils/table';
66
import { SCOPE_DESCRIPTIONS } from '../utils/auth-config';
77
import { AuthenticationError } from '../types/auth';
8+
import { displayBackendUrl } from '../utils/display';
89

910
export function registerWhoamiCommand(program: Command) {
1011
program
@@ -51,7 +52,7 @@ export function registerWhoamiCommand(program: Command) {
5152
console.log(chalk.gray(`🏷️ Username: ${userInfo.preferred_username}`));
5253
}
5354
console.log(chalk.gray(`✅ Email Verified: ${userInfo.email_verified ? 'Yes' : 'No'}`));
54-
console.log(chalk.gray(`🌐 Using backend: ${backendUrl}\n`));
55+
console.log(chalk.gray(`🌐 Using backend: ${displayBackendUrl(backendUrl)}\n`));
5556

5657
// Display account info in table format if accounts exist
5758
if (accounts.length > 0) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Utility functions for displaying information to users
3+
*/
4+
5+
/**
6+
* Masks the internal backend URL for better user experience
7+
* Only masks the default DeployStack backend, preserves custom backends as-is
8+
*
9+
* @param backendUrl - The actual backend URL used for API calls
10+
* @returns The URL to display to the user
11+
*/
12+
export function displayBackendUrl(backendUrl: string): string {
13+
if (backendUrl === 'https://cloud-api.deploystack.io') {
14+
return 'https://cloud.deploystack.io';
15+
}
16+
return backendUrl;
17+
}

0 commit comments

Comments
 (0)