Refactor Frontend to Use Centralized API Configuration#340
Open
rishabh0510rishabh wants to merge 1 commit intoYugenjr:masterfrom
Open
Refactor Frontend to Use Centralized API Configuration#340rishabh0510rishabh wants to merge 1 commit intoYugenjr:masterfrom
rishabh0510rishabh wants to merge 1 commit intoYugenjr:masterfrom
Conversation
Update frontend dependencies and lockfile, add lint output, and apply fixes across multiple UI/data files. Changes touch BadgeCollection, Friends, GoalDashboard, Leaderboard, useGrindMapData hook, and api utils to improve data fetching, error handling, and rendering logic (fixes badge rendering, friends list/ordering, leaderboard behavior, and grindmap data mapping).
Owner
|
KINDLY DONT PUSH THE PACKAGE LOCK FILES AND CAN YOU PLEASE SAY THE EXPLANATION REMOVAL OF SUCH LINES |
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.
📝 Description
This PR refactors the frontend codebase to use a centralized
API_BASE_URLconstant for all API requests. This change removes hardcoded API strings (e.g.,http://localhost:5000/api,/api/), making the application easier to configure for different environments (local, staging, production) viaconfigor environment variables.🚀 Changes
frontend/src/utils/api.jsto correctly exportAPI_BASE_URL.API_BASE_URLto useimport.meta.env.VITE_API_URLwith a fallback tohttp://localhost:5001/api.import.meta.envaccess to prevent runtime errors in non-Vite environments (e.g., during testing or script execution).frontend/src/hooks/useGrindMapData.jsto import and useAPI_BASE_URL.frontend/src/components/Leaderboard.jsxto useAPI_BASE_URL.frontend/src/components/GoalDashboard.jsx,Friends.jsx, andBadgeCollection.jsxto replace hardcoded API paths.frontend/src/utils/api.jsthat were causing linting errors.frontend/package.jsonwhich was found to be empty, ensuring standard dependencies and scripts are present.🔍 Verification
npm run lint- PASSED.npx vite build- PASSED (Exit Code 0).verify_api.mjs) to test the mock API functions andAPI_BASE_URLlogic in a simulated Node environment. All checks passed.📦 Dependencies
package.json.Related issues #321
Labels: ECWoC26