Skip to content

Commit d576460

Browse files
committed
Changed it to dynamically resolve the base path from window.location.pathname
1 parent f5737f3 commit d576460

3 files changed

Lines changed: 9 additions & 86 deletions

File tree

springdoc-openapi-starter-common-mcp/src/main/frontend/src/api/mcpAdminApi.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import type { McpToolInfo, McpToolExecutionRequest, McpToolExecutionResponse } from '../types'
22

3-
const BASE_PATH = '/api/mcp-admin'
3+
function resolveBasePath(): string {
4+
const { pathname } = window.location
5+
const mcpUiIndex = pathname.indexOf('/mcp-ui')
6+
const prefix = mcpUiIndex > 0 ? pathname.substring(0, mcpUiIndex) : ''
7+
return `${prefix}/api/mcp-admin`
8+
}
9+
10+
const BASE_PATH = resolveBasePath()
411

512
export async function fetchTools(): Promise<McpToolInfo[]> {
613
const res = await fetch(`${BASE_PATH}/tools`)

0 commit comments

Comments
 (0)