From f6a639302e479d6eeaf3b9b5ef1a27b5dfae020d Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 19 Feb 2025 13:49:29 -0800 Subject: [PATCH] fix(starter): add temp logging to debug executor inability to resolve envvars --- providers/service.ts | 8 +++++++- tools/index.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) 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 }),