fix: return svg response for streak rate limit#2208
Conversation
|
@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. |
|
👋 Hey @lowkeyd3v, it looks like you didn't use our PR template! The section Please update your PR description to include all required sections so we can review this properly:
You can find the full template in CONTRIBUTING.md. Just edit your PR description and the |
|
👋 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:
We look forward to reviewing your PR once an issue is linked! 🚀 |
|
👋 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:
A maintainer will review your PR shortly. Hang tight! 🚀 |
Description
This PR fixes inconsistent rate-limit behavior for
/api/streak.Previously, when
/api/streakexceeded 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/streakinsidemiddleware.tsReturn
image/svg+xmlon429 Too Many RequestsPreserve existing JSON rate-limit behavior for other API routes
Preserve rate-limit headers:
X-RateLimit-LimitX-RateLimit-RemainingX-RateLimit-ResetVerification
Tested locally by sending repeated requests to:
/api/streak?user=octocatAfter exceeding the rate limit, the endpoint returned:
This keeps badge embeds SVG-compatible instead of returning a JSON response.
Pillar
🐞 Bug Fix
Checklist