mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-10 14:55:16 -05:00
## Changes 🏗️ We noticed that in some pages ( `/build` _mainly_ ), where a lot of API calls are fired in parallel using the old `BackendAPI`( _running many agent executions_ ) the performance became worse. That is because the `BackendAPI` was proxied via [server actions](https://nextjs.org/docs/14/app/building-your-application/data-fetching/server-actions-and-mutations) ( _to make calls to our Backend on the Next.js server_ ). Looks like server actions don't run in parallel, and their performance is also subpar, given that we are not hosted on Vercel (they don't utilise the edge middleware). These changes cause all `BackendAPI` calls to be proxied via the Next.js `/api/` route when executed on the browser; when executed on the server, they bypass the proxy and directly access the API. Hopefully we gain: - 🚀 Better Performance - API routes are faster than server actions for this use case - 🔧 Less Magic - Direct fetch calls instead of hidden server action complexity - ♻️ Code Reuse - Leveraging the existing proxy infrastructure used by react-query - 🎯 Cleaner Architecture - Single proxy pattern for all API calls - 🔒 Same Security - Still uses server-side authentication with httpOnly cookies ## Checklist 📋 ### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] E2E tests pass - [x] Click through the app, there is no issues - [x] Agent executions are fast again in the builder - [x] Test file uploads