Skip to content

[pages] incorrect API route validation #83067

Closed

Description

@bgub

In the source code, we export

export type NextApiHandler<T = any> = (
  req: NextApiRequest,
  res: NextApiResponse<T>
) => unknown | Promise<unknown>

But the validator expects

(req: any, res: any) => Promise<Response | void> | Response | void

This was a mistake on my part -- the first type is accurate and the second is not.

Referenced by @WilliamIPark, @ecl1ps, @MadaShindeInai, @HimanshuKumarDutt094, and @soulchild in #82877 (tagging so you can follow this issue)

Activity

  1. added theissue type on Aug 26, 2025
  2. added
    invalid linkThe issue was auto-closed due to a missing/invalid reproduction link. A new issue should be opened.
    on Aug 26, 2025
  3. locked and limited conversation to collaborators on Aug 26, 2025
  4. removed
    invalid linkThe issue was auto-closed due to a missing/invalid reproduction link. A new issue should be opened.
    on Aug 26, 2025
  5. reopened this on Aug 26, 2025
  6. self-assigned this
    on Aug 26, 2025
  7. deleted a comment from github-actions on Aug 26, 2025
  8. changed the title [-][pages] API route validation is too strict[/-] [+][pages] incorrect API route validation[/+] on Aug 26, 2025
  9. added 2 commits that reference this issue on Aug 27, 2025
    2880238
    d5add9c
  10. added a commit that references this issue on Sep 8, 2025
    d6c5fcb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

TypeScriptRelated to types with Next.js.

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions