diff --git a/providers/service.ts b/providers/service.ts index 4aad5c9d1a..407f9e27a6 100644 --- a/providers/service.ts +++ b/providers/service.ts @@ -249,7 +249,13 @@ export async function executeProviderRequest( } async function makeProxyRequest(providerId: string, payload: any, apiKey: string) { - const response = await fetch('/api/proxy', { + const baseUrl = process.env.NEXT_PUBLIC_APP_URL + if (!baseUrl) { + throw new Error('NEXT_PUBLIC_APP_URL environment variable is not set') + } + + const proxyUrl = new URL('/api/proxy', baseUrl).toString() + const response = await fetch(proxyUrl, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/tools/index.ts b/tools/index.ts index 3b8e3738ba..30925f2738 100644 --- a/tools/index.ts +++ b/tools/index.ts @@ -102,7 +102,13 @@ export async function executeTool( } // For external APIs, use the proxy - const response = await fetch('/api/proxy', { + const baseUrl = process.env.NEXT_PUBLIC_APP_URL + if (!baseUrl) { + throw new Error('NEXT_PUBLIC_APP_URL environment variable is not set') + } + + const proxyUrl = new URL('/api/proxy', baseUrl).toString() + const response = await fetch(proxyUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ toolId, params }),