Commit Graph

1 Commits

Author SHA1 Message Date
James Anderson 35bb1a2250 fix(pages-router): return 405 with Allow: GET, HEAD on POST to static pages (#1631)
Pages Router previously rendered HTML for any HTTP method, including
POST/PUT/DELETE, on static (no `getServerSideProps`) pages — masking
client bugs that Next.js surfaces as 405.

Mirrors Next.js's behavior in `base-server.ts` (the
`(typeof components.Component === 'string' || isSSG)` gate), which
rejects non-GET/HEAD methods on static pages with
`Allow: GET, HEAD` and a `Method Not Allowed` body. Pages with
`getServerSideProps` continue to accept any method, since user code
may legitimately read `req.method` inside gSSP.

The new `resolvePagesPageMethodResponse` helper is wired into both
the dev-server SSR handler and the prod-server pages-server-entry, and
skips `/_error`, `/404`, `/500`, data requests, and explicit status
overrides — matching the upstream carve-outs.

Refs #1463. The `res.revalidate()` portion of #1463 is left for a
follow-up.
2026-05-28 14:05:30 +01:00