File tree Expand file tree Collapse file tree 2 files changed +5
-12
lines changed
services/backend/src/routes/mcp/installations Expand file tree Collapse file tree 2 files changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { getDb } from '../../../db';
99import { mcpServers , mcpServerInstallations } from '../../../db/schema.sqlite' ;
1010import { eq } from 'drizzle-orm' ;
1111import { nanoid } from 'nanoid' ;
12+ import { GlobalSettings } from '../../../global-settings' ;
1213import {
1314 TEAM_ID_PARAM_SCHEMA ,
1415 OAUTH_AUTHORIZE_REQUEST_SCHEMA ,
@@ -172,13 +173,8 @@ export default async function authorizeRoute(server: FastifyInstance) {
172173 const installationId = nanoid ( ) ;
173174 const authService = new OAuthAuthorizationService ( request . log ) ;
174175
175- // Build backend URL for OAuth callback
176- const protocol = process . env . NODE_ENV === 'production' ? 'https' : 'http' ;
177- const host = process . env . HOST || 'localhost' ;
178- const port = process . env . PORT || '3000' ;
179- const backendUrl = process . env . NODE_ENV === 'production'
180- ? `${ protocol } ://${ host } `
181- : `${ protocol } ://${ host } :${ port } ` ;
176+ // Get backend URL from global settings for OAuth callback
177+ const backendUrl = await GlobalSettings . get ( 'global.backend_url' , 'http://localhost:3000' ) ;
182178 const redirectUri = `${ backendUrl } /api/teams/${ teamId } /mcp/installations/${ installationId } /oauth/callback` ;
183179
184180 // Discover OAuth endpoints and check for dynamic client registration
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { OAuthTokenService } from '../../../services/OAuthTokenService';
66import { OAuthDiscoveryService } from '../../../services/OAuthDiscoveryService' ;
77import { encrypt } from '../../../utils/encryption' ;
88import { GlobalSettingsInitService } from '../../../global-settings' ;
9+ import { GlobalSettings } from '../../../global-settings' ;
910import { nanoid } from 'nanoid' ;
1011import {
1112 OAUTH_CALLBACK_QUERY_SCHEMA ,
@@ -201,11 +202,7 @@ export default async function oauthCallbackRoute(server: FastifyInstance) {
201202 }
202203
203204 // Construct redirect URI (must match what was sent in authorization request)
204- const protocol = process . env . NODE_ENV === 'production' ? 'https' : 'http' ;
205- const host = process . env . HOST || 'localhost' ;
206- const port = process . env . PORT || '3000' ;
207- const backendUrl =
208- process . env . NODE_ENV === 'production' ? `${ protocol } ://${ host } ` : `${ protocol } ://${ host } :${ port } ` ;
205+ const backendUrl = await GlobalSettings . get ( 'global.backend_url' , 'http://localhost:3000' ) ;
209206 const redirectUri = `${ backendUrl } /api/teams/${ teamId } /mcp/installations/${ installationId } /oauth/callback` ;
210207
211208 // Get client_id from installation (may be dynamically registered)
You can’t perform that action at this time.
0 commit comments