Skip to content

fix: add /api/stats and /api/og to rate limiting middleware#904

Merged
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
KaparthyReddy:fix/rate-limit-stats-og-endpoints
May 28, 2026
Merged

fix: add /api/stats and /api/og to rate limiting middleware#904
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
KaparthyReddy:fix/rate-limit-stats-og-endpoints

Conversation

@KaparthyReddy
Copy link
Copy Markdown
Contributor

Fixes #902

Description

Both /api/stats and /api/og endpoints were excluded from the rate limiting middleware matcher, allowing unlimited requests with no throttling. /api/og is especially severe as it always passes bypassCache: true, meaning every call triggers a fresh GitHub API request regardless of volume.

This fix adds both routes to the middleware matcher in middleware.ts, consistent with how /api/streak and /api/github are already protected.

Files changed: middleware.ts only — 1 line changed in the matcher array, JSDoc comment updated.

Pillar

  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

N/A — middleware change, no SVG output affected.

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors.
  • My commits follow the Conventional Commits format.
  • I have updated README.md if I added a new theme or URL parameter.
  • I have starred the repo.
  • I have made sure that I have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard.
  • (Recommended) I joined the CommitPulse Discord community.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 28, 2026

@KaparthyReddy is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

👋 Hey @KaparthyReddy, welcome to CommitPulse! 🎉

Thanks for opening your first pull request — this is a big deal and we appreciate the effort!

While you wait for a review, please double-check:

  • ✅ You've read the CONTRIBUTING.md checklist
  • npm run lint, npm run format, and npm run test all pass locally
  • ✅ Your PR has a visual preview if it touches any SVG output
  • 💬 You've joined our Discord for faster PR feedback

A maintainer will review your PR shortly. Hang tight! 🚀

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label May 28, 2026
@github-actions
Copy link
Copy Markdown

🚨 Hey @KaparthyReddy, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

Please fix the issues before this can be reviewed. Here's how:

1. Run checks locally before pushing:

npm run format:check   # Check Prettier formatting
npm run lint           # Run ESLint
npm run typecheck      # TypeScript type check
npm run test           # Run unit tests (Vitest)
npm run build          # Verify production build passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

- Both endpoints call fetchGitHubContributions() on every request
- /api/og always bypasses cache, making every call a fresh GitHub API hit
- Add /api/stats/:path* and /api/og/:path* to middleware matcher
- Consistent with how /api/streak and /api/github are already protected
@KaparthyReddy KaparthyReddy force-pushed the fix/rate-limit-stats-og-endpoints branch from 8323404 to 8a1ed7e Compare May 28, 2026 09:15
@github-actions github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label May 28, 2026
@github-actions github-actions Bot added the type:bug Something isn't working as expected label May 28, 2026
@JhaSourav07 JhaSourav07 added GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:exceptional Outstanding contribution with exceptional implementation quality, testing. gssoc:approved PR has been reviewed and accepted for valid contribution points mentor:Aamod007 labels May 28, 2026
@JhaSourav07 JhaSourav07 merged commit 1a52708 into JhaSourav07:main May 28, 2026
6 of 7 checks passed
@github-actions github-actions Bot added this to the GSSoC 2026 milestone May 28, 2026
@github-actions
Copy link
Copy Markdown

🎉 Congratulations @KaparthyReddy! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

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

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:exceptional Outstanding contribution with exceptional implementation quality, testing. type:bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] /api/stats and /api/og endpoints are excluded from rate limiting middleware

3 participants