fix(http): add axios interceptor that blocks disallowed HTTP methods#695
fix(http): add axios interceptor that blocks disallowed HTTP methods#695anshul23102 wants to merge 1 commit into
Conversation
…on API calls GET /api/repos was reachable via HTTP DELETE because the client had no method guard. A misconfigured component or an injected request could send a destructive method to a read-only endpoint. Add an apiClient axios instance with a request interceptor that: 1. Rejects any request whose HTTP method is not in the standard allow-list. 2. Explicitly rejects DELETE requests targeting /api/repos since that endpoint is read-only and should never receive destructive methods from the client. Components that interact with the backend should import apiClient instead of the global axios instance so all requests pass through the guard. Closes GitMetricsLab#686
|
Warning Review limit reached
More reviews will be available in 52 minutes and 54 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ✨ 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 |
✅ Deploy Preview for github-spy ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Description
The client had no guard preventing destructive HTTP methods from being sent to read-only API endpoints. A misconfigured component could inadvertently send a DELETE request to GET /api/repos, which the backend might process without a method validation check of its own.
Root Cause
No client-side method validation existed. Components used the global axios instance directly with no restrictions on which HTTP methods could be used with which endpoints.
Related Issue
Closes #686
Type of Change
Changes Made
Testing Done
Checklist