mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-07 22:33:57 -05:00
feat(platform): centralize api calls in nextjs for token handling (#10222)
This PR helps to send all the React query requests through a Next.js server proxy. It works something like this: when a user sends a request, our custom mutator sends a request to the proxy server, where we add the auth token to the header and send it to the backend again. 🌐 Users can send a client-side request directly to the backend server because their browser does have access to auth tokens, so they need to go via the Next.js server. 🚀 ### Changes 🏗️ - Change the position of the generated client, mutator, and transfer inside `/src/app/api` - Update the mutator to send the request to the proxy server - Add a proxy server at `/api/proxy`, which handles the request using `makeAuthenticatedRequest` and `makeAuthenticatedFileUpload` helpers and sends the request to the backend - Remove `getSupabaseClient`, because we do not have access to the auth token on client side, hence no need 🔑 - Update Orval configs to generate the client at the new position - Added new backend updates to the auto-generated client. ### 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] The setting page is using React Query and is working fine. - [x] The mutator is sending requests to the proxy server correctly. - [x] The proxy server is handling requests correctly. - [x] The response handling is correct in both the proxy server and the custom mutator.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -179,4 +179,4 @@ autogpt_platform/backend/settings.py
|
||||
.claude/settings.local.json
|
||||
|
||||
# Auto generated client
|
||||
autogpt_platform/frontend/src/api/__generated__
|
||||
autogpt_platform/frontend/src/app/api/__generated__
|
||||
|
||||
Reference in New Issue
Block a user