AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): Add fallback for `NEXT_PUBLIC_FRONTEND_BASE_URL` to API proxy (#10299)
Reinier van der Leerb1f3122243c2
diff --git a/autogpt_platform/backend/.env.example b/autogpt_platform/backend/.env.exampleindex 395248f7ed..18343d7725 100644--- a/autogpt_platform/backend/.env.example+++ b/autogpt_platform/backend/.env.example@@ -55,9 +55,9 @@ RABBITMQ_DEFAULT_PASS=k0VMxyIJF9S35f3x2uaw5IWAl6Y536O7## GCS bucket is required for marketplace and library functionalityMEDIA_GCS_BUCKET_NAME=-## For local development, you may need to set NEXT_PUBLIC_FRONTEND_BASE_URL for the OAuth flow+## For local development, you may need to set FRONTEND_BASE_URL for the OAuth flow## for integrations to work. Defaults to the value of PLATFORM_BASE_URL if not set.-# NEXT_PUBLIC_FRONTEND_BASE_URL=http://localhost:3000+# FRONTEND_BASE_URL=http://localhost:3000## PLATFORM_BASE_URL must be set to a *publicly accessible* URL pointing to your backend## to use the platform's webhook-related functionality.diff --git a/autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts b/autogpt_platform/frontend/src/app/api/mutators/custom-mutator.tsindex 53b899dfd5..e6b66d762e 100644--- a/autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts+++ b/autogpt_platform/frontend/src/app/api/mutators/custom-mutator.ts@@ -1,4 +1,6 @@-const BASE_URL = `${process.env.NEXT_PUBLIC_FRONTEND_BASE_URL}/api/proxy`; // Sending request via nextjs Server+const FRONTEND_BASE_URL =+ process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || "http://localhost:3000";+const API_PROXY_BASE_URL = `${FRONTEND_BASE_URL}/api/proxy`; // Sending request via nextjs Serverconst getBody = <T>(c: Response | Request): Promise<T> => {const contentType = c.headers.get("content-type");@@ -43,7 +45,7 @@ export const customMutator = async <T = any>(? "?" + new URLSearchParams(params).toString(): "";- const response = await fetch(`${BASE_URL}${url}${queryString}`, {+ const response = await fetch(`${API_PROXY_BASE_URL}${url}${queryString}`, {...requestOptions,method,headers,