Skip to content

fix(http): add axios interceptor that blocks disallowed HTTP methods#695

Open
anshul23102 wants to merge 1 commit into
GitMetricsLab:mainfrom
anshul23102:fix/686-http-method-validation
Open

fix(http): add axios interceptor that blocks disallowed HTTP methods#695
anshul23102 wants to merge 1 commit into
GitMetricsLab:mainfrom
anshul23102:fix/686-http-method-validation

Conversation

@anshul23102
Copy link
Copy Markdown
Contributor

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

  • Bug fix

Changes Made

  • src/utils/apiClient.ts: New pre-configured axios instance with a request interceptor that rejects requests using unlisted HTTP methods and explicitly blocks DELETE requests to the /api/repos endpoint.

Testing Done

  1. GET request to /api/repos: passes through as normal.
  2. DELETE request to /api/repos: rejected client-side with a descriptive error.
  3. Standard POST/PUT/PATCH requests: pass through normally.

Checklist

  • My code follows the style and formatting of this project
  • I have tested my changes locally and they work as expected
  • There are no merge conflicts with the base branch
  • This PR is linked to the correct issue

…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
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Warning

Review limit reached

@anshul23102, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 926725e0-b0eb-4052-8594-a2d020e9c7f4

📥 Commits

Reviewing files that changed from the base of the PR and between 53f820b and f8f1e42.

📒 Files selected for processing (1)
  • src/utils/apiClient.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 3, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit f8f1e42
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a20294eee17a200082b69d3
😎 Deploy Preview https://deploy-preview-695--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] GET /api/repos Accepts DELETE Method - HTTP Method Not Validated

1 participant