diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index 646514eee8..e36eeba12e 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -354,8 +354,19 @@ export const getToolServersData = async (servers: object[]) => { .filter((server) => server?.config?.enable) .map(async (server) => { let error = null; + + let toolServerToken = null; + const auth_type = server?.auth_type ?? 'bearer'; + if (auth_type === 'bearer') { + toolServerToken = server?.key; + } else if (auth_type === 'none') { + // No authentication + } else if (auth_type === 'session') { + toolServerToken = localStorage.token; + } + const data = await getToolServerData( - (server?.auth_type ?? 'bearer') === 'bearer' ? server?.key : localStorage.token, + toolServerToken, (server?.path ?? '').includes('://') ? server?.path : `${server?.url}${(server?.path ?? '').startsWith('/') ? '' : '/'}${server?.path}` diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index d0453dc5ed..d4205bb9ee 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -222,8 +222,19 @@ if (toolServer) { console.log(toolServer); + + let toolServerToken = null; + const auth_type = toolServer?.auth_type ?? 'bearer'; + if (auth_type === 'bearer') { + toolServerToken = toolServer?.key; + } else if (auth_type === 'none') { + // No authentication + } else if (auth_type === 'session') { + toolServerToken = localStorage.token; + } + const res = await executeToolServer( - (toolServer?.auth_type ?? 'bearer') === 'bearer' ? toolServer?.key : localStorage.token, + toolServerToken, toolServer.url, data?.name, data?.params,