Skip to content

fix: return svg response for streak rate limit#2208

Closed
lowkeyd3v wants to merge 1 commit into
JhaSourav07:mainfrom
lowkeyd3v:fix-streak-rate-limit-svg
Closed

fix: return svg response for streak rate limit#2208
lowkeyd3v wants to merge 1 commit into
JhaSourav07:mainfrom
lowkeyd3v:fix-streak-rate-limit-svg

Conversation

@lowkeyd3v
Copy link
Copy Markdown

@lowkeyd3v lowkeyd3v commented Jun 1, 2026

Description

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

@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 added the needs-details This PR is missing required description details. label Jun 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

👋 Hey @lowkeyd3v, it looks like you didn't use our PR template!

The section ## Description is missing from your PR description.

Please update your PR description to include all required sections so we can review this properly:

  • ## Description — What does this PR do? Which issue does it fix?
  • ## Pillar — Which contribution pillar does this fall under?
  • ## Checklist — Have you ticked off the quality checklist?

You can find the full template in CONTRIBUTING.md. Just edit your PR description and the needs-details label will be removed automatically. 🙌

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

👋 Hey @lowkeyd3v! Thanks for your contribution! 🎉

Unfortunately, this PR has been automatically closed because it is not linked to any open issue.

To resolve this, please do the following:

  1. Link a valid open issue by editing your PR description to include a closing keyword (e.g., Fixes #<issue-number>).
  2. Reopen this PR once the link is added.

💡 You can link multiple issues if needed (e.g. Fixes #12, Closes #34).
If you're working on something that doesn't have an issue yet, please open one first and then link it here.

We look forward to reviewing your PR once an issue is linked! 🚀

@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 closed this Jun 1, 2026
@github-actions github-actions Bot removed the needs-details This PR is missing required description details. label 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.

1 participant