fix(server): reject unsupported static asset methods#2714
Conversation
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc914369bc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| const resolved = await resolveStaticFile(staticFile); | ||
| if (!resolved) return false; | ||
| if (rejectUnsupportedStaticMethod(req, res)) return true; |
There was a problem hiding this comment.
Route public-file methods through the new rejection check
For production requests such as POST /robots.txt, this new uncached-path check is never reached: the Pages Router's serveFilesystemRoute callback returns false for every non-GET/HEAD request at prod-server.ts:2001, while the App Router's resolvePublicFileRoute does the same before producing a static-file signal. Consequently, real public files still fall through to page routing and usually return 404 rather than the intended 405; the added uncached test only calls this private helper directly and does not exercise either request pipeline. Remove or revise those upstream method gates so existing public files reach this check while missing files still fall through.
AGENTS.md reference: AGENTS.md:L183-L192
Useful? React with 👍 / 👎.
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
Summary
Next.js parity
Next.js checks filesystem-route methods before serveStatic and returns 405 with Allow: GET, HEAD. Vinext's early App and Pages asset paths previously bypassed its later method guard.
Test plan