Skip to content

fix: return svg response for streak rate limit#2210

Closed
lowkeyd3v wants to merge 2 commits into
JhaSourav07:mainfrom
lowkeyd3v:fix-streak-rate-limit-svg
Closed

fix: return svg response for streak rate limit#2210
lowkeyd3v wants to merge 2 commits into
JhaSourav07:mainfrom
lowkeyd3v:fix-streak-rate-limit-svg

Conversation

@lowkeyd3v
Copy link
Copy Markdown

Description

Fixes #2207

This PR fixes inconsistent rate-limit behavior for /api/streak.

Previously, when /api/streak exceeded the middleware rate limit, the response returned JSON (application/json) even though the endpoint is intended to be consumed as an SVG image badge.

Changes made

  • Added a special-case for /api/streak inside middleware.ts

  • Return image/svg+xml on 429 Too Many Requests

  • Preserve existing JSON rate-limit behavior for other API routes

  • Preserve rate-limit headers:

    • X-RateLimit-Limit
    • X-RateLimit-Remaining
    • X-RateLimit-Reset

Verification

Tested locally by sending repeated requests to:

/api/streak?user=octocat

After exceeding the rate limit, the endpoint returned:

HTTP/1.1 429 Too Many Requests
content-type: image/svg+xml

This keeps badge embeds SVG-compatible instead of returning a JSON response.


Pillar

🐞 Bug Fix


Checklist

  • Code follows the project style
  • Changes are scoped to the reported issue
  • Tested locally
  • No unrelated files changed
  • Existing functionality for other API routes remains unchanged

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

👋 Hey @lowkeyd3v, 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 Jun 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

🚨 Hey @lowkeyd3v, 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. 💪

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Jun 1, 2026

@lowkeyd3v 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 github-actions Bot removed the status:blocked This PR is blocked due to a failing CI check. label Jun 1, 2026
@lowkeyd3v lowkeyd3v closed this by deleting the head repository Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/api/streak rate-limit response returns JSON instead of SVG

1 participant