Standardize frontend API calls with centralized axios client and backend path alignment#56
Merged
csecrestjr merged 1 commit intoAug 31, 2025
Conversation
csecrestjr
marked this pull request as ready for review
August 31, 2025 17:06
Copilot
AI
changed the title
[WIP] Frontend: standardize API client, use relative /api paths, add dev proxy (keep backend paths)
Standardize frontend API calls with centralized axios client and backend path alignment
Aug 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adapts the frontend to use existing backend API paths and introduces a centralized axios client for consistent authentication header management across all requests.
Key Changes
Centralized API Client
Created
/frontend/chat-ui/src/api.jswith:Authorization: Bearer ${token}header injection from localStoragex-api-keyheader support viaVITE_API_KEYenvironment variableVITE_API_BASE_URLfor different deployment environmentsFrontend Path Standardization
Updated frontend components to use backend's existing API structure:
user_login.jsnow calls/api/auth/logininstead of hardcodedhttp://localhost:5000/auth/login/api/admin/usersand/api/admin/keys/api/keys/validate-keyTopBar.jsxnow uses centralized API client for conversation deletion viaapi.delete(/conversations/${id})Development Experience Improvements
/api/*,/conversations/*, and/messages/*routes tohttp://localhost:5000.env.examplewith documented configuration options.gitignoreto exclude build artifactsAuthentication Flow Enhancement
The centralized approach ensures:
x-api-keyusage)Backend Compatibility
This PR does not modify any backend code. It adapts the frontend to work with the existing backend routes that are already mounted at:
/api/auth/*for authentication/api/admin/*for admin operations/api/keys/*for key management/conversations/*for chat conversations/messages/*for chat messagesTesting
npm run build)The changes maintain backward compatibility while providing a more maintainable and consistent API interaction pattern for future development.
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.