Skip to content

bug: Potential stale/incorrect rate-limit headers on API responses #3602

@Aditya8369

Description

@Aditya8369

Description

Middleware sets rate-limit headers on the NextResponse.next() response, but for routes that return their own responses (or fail/short-circuit), headers may be missing or inconsistent. The middleware does not guarantee headers are added to all returned responses in a consistent way.

Steps to Reproduce

  1. Call any protected API route, e.g. GET /api/streak?user=torvalds.
  2. Repeat quickly until rate limiting triggers.
  3. Inspect response headers in DevTools → Network.

Expected Behavior

For every request (success or 429), rate-limit headers are present and correct:
X-RateLimit-Limit
X-RateLimit-Remaining
X-RateLimit-Reset

Screenshots / Logs

No response

GitHub Username (If applicable)

No response

Environment

Chrome

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions