|
1 | | -import { getEnv } from '@/lib/env' |
2 | 1 | import { createLogger } from '@/lib/logs/console/logger' |
3 | 2 | import { createMcpToolId } from '@/lib/mcp/utils' |
| 3 | +import { getBaseUrl } from '@/lib/urls/utils' |
4 | 4 | import { getAllBlocks } from '@/blocks' |
5 | 5 | import type { BlockOutput } from '@/blocks/types' |
6 | 6 | import { BlockType } from '@/executor/consts' |
@@ -261,8 +261,7 @@ export class AgentBlockHandler implements BlockHandler { |
261 | 261 | } |
262 | 262 | } |
263 | 263 |
|
264 | | - const appUrl = getEnv('NEXT_PUBLIC_APP_URL') |
265 | | - const url = new URL(`${appUrl}/api/mcp/tools/discover`) |
| 264 | + const url = new URL('/api/mcp/tools/discover', getBaseUrl()) |
266 | 265 | url.searchParams.set('serverId', serverId) |
267 | 266 | if (context.workspaceId) { |
268 | 267 | url.searchParams.set('workspaceId', context.workspaceId) |
@@ -316,7 +315,7 @@ export class AgentBlockHandler implements BlockHandler { |
316 | 315 | } |
317 | 316 | } |
318 | 317 |
|
319 | | - const execResponse = await fetch(`${appUrl}/api/mcp/tools/execute`, { |
| 318 | + const execResponse = await fetch(`${getBaseUrl()}/api/mcp/tools/execute`, { |
320 | 319 | method: 'POST', |
321 | 320 | headers, |
322 | 321 | body: JSON.stringify({ |
@@ -640,7 +639,7 @@ export class AgentBlockHandler implements BlockHandler { |
640 | 639 | ) { |
641 | 640 | logger.info('Using HTTP provider request (browser environment)') |
642 | 641 |
|
643 | | - const url = new URL('/api/providers', getEnv('NEXT_PUBLIC_APP_URL') || '') |
| 642 | + const url = new URL('/api/providers', getBaseUrl()) |
644 | 643 | const response = await fetch(url.toString(), { |
645 | 644 | method: 'POST', |
646 | 645 | headers: { 'Content-Type': 'application/json' }, |
|
0 commit comments