fix: replace hardcoded API URL with environment variable#64
fix: replace hardcoded API URL with environment variable#64ShrutiiShinde05 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthrough
ChangesAxios API URL from environment variable
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi! @niharika-mente I've submitted a PR for this issue. The hardcoded API URL has been replaced with an environment-based configuration using I'd appreciate a review when you have time. Thank you! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/src/lib/axios.js (1)
3-3: Add environment variable setup documentation and .env file for development.The change introduces a silent fallback to
"/api"whenVITE_API_URLis not set. While the/apipath correctly matches the backend route structure (/api/notesand/api/auth), the current setup lacks configuration guidance:
- No
.envor.env.exampleexists in the frontend directory to document the variable- No CI/CD pipeline is configured to set
VITE_API_URLfor different deployment environments- No documentation explains that this variable is optional but useful for non-relative-path deployments (e.g., separate domains, proxy configurations)
For development flexibility and clarity, add a
frontend/.env.exampledocumentingVITE_API_URL, and update the README to explain when and how to override the default/apifallback. This improves maintainability without blocking the current change.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@frontend/src/lib/axios.js` at line 3, The code change in axios.js correctly implements a fallback to "/api" for the API_URL when VITE_API_URL is not set, but the setup lacks proper documentation. Create a frontend/.env.example file that documents the VITE_API_URL environment variable with an example value, and update the project README to explain that VITE_API_URL is an optional configuration variable useful for deployments where the frontend and backend are on different domains or behind a proxy. Make clear that when not set, the default relative path "/api" is used, matching the backend route structure.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@frontend/src/lib/axios.js`:
- Line 3: The code change in axios.js correctly implements a fallback to "/api"
for the API_URL when VITE_API_URL is not set, but the setup lacks proper
documentation. Create a frontend/.env.example file that documents the
VITE_API_URL environment variable with an example value, and update the project
README to explain that VITE_API_URL is an optional configuration variable useful
for deployments where the frontend and backend are on different domains or
behind a proxy. Make clear that when not set, the default relative path "/api"
is used, matching the backend route structure.
Description
Replaced the hardcoded API URL (
http://localhost:5001/api) with an environment-based configuration.Changes
import.meta.env.VITE_API_URL || "/api"Benefits
Summary by CodeRabbit