[PR #285] [MERGED] Default API route Content-Type to application/octet-stream #444

Closed
opened 2026-05-06 12:39:50 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/285
Author: @southpolesteve
Created: 3/6/2026
Status: Merged
Merged: 3/6/2026
Merged by: @southpolesteve

Base: mainHead: fix/api-route-content-type-default


📝 Commits (2)

  • 9c605c4 Default API route Content-Type to application/octet-stream
  • 8edf54f Improve test comment for Content-Type assertion

📊 Changes

3 files changed (+24 additions, -1 deletions)

View changed files

📝 packages/vinext/src/server/prod-server.ts (+4 -1)
tests/fixtures/pages-basic/pages/api/no-content-type.ts (+9 -0)
📝 tests/pages-router.test.ts (+11 -0)

📄 Description

Summary

  • When a Pages Router API route handler calls res.end() without explicitly setting a Content-Type header, the production server was falling back to text/html. This could cause browsers to render response bodies as HTML when the developer intended to return plain data.
  • Changed the API route fallback from text/html to application/octet-stream, which is the safe default for arbitrary content. The SSR page rendering path still correctly defaults to text/html.

Changes

  • packages/vinext/src/server/prod-server.ts: Changed the content-type fallback from "text/html" to "application/octet-stream" for API route responses (line 894).
  • tests/fixtures/pages-basic/pages/api/no-content-type.ts: New fixture API route that returns a response without setting Content-Type.
  • tests/pages-router.test.ts: New test verifying the API route content-type default is not text/html.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/285 **Author:** [@southpolesteve](https://github.com/southpolesteve) **Created:** 3/6/2026 **Status:** ✅ Merged **Merged:** 3/6/2026 **Merged by:** [@southpolesteve](https://github.com/southpolesteve) **Base:** `main` ← **Head:** `fix/api-route-content-type-default` --- ### 📝 Commits (2) - [`9c605c4`](https://github.com/cloudflare/vinext/commit/9c605c48244d4d0b93a5a670ffc6358df57f3498) Default API route Content-Type to application/octet-stream - [`8edf54f`](https://github.com/cloudflare/vinext/commit/8edf54ff7795937d5c108af04458e2d2724449d9) Improve test comment for Content-Type assertion ### 📊 Changes **3 files changed** (+24 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/prod-server.ts` (+4 -1) ➕ `tests/fixtures/pages-basic/pages/api/no-content-type.ts` (+9 -0) 📝 `tests/pages-router.test.ts` (+11 -0) </details> ### 📄 Description ## Summary - When a Pages Router API route handler calls `res.end()` without explicitly setting a `Content-Type` header, the production server was falling back to `text/html`. This could cause browsers to render response bodies as HTML when the developer intended to return plain data. - Changed the API route fallback from `text/html` to `application/octet-stream`, which is the safe default for arbitrary content. The SSR page rendering path still correctly defaults to `text/html`. ## Changes - `packages/vinext/src/server/prod-server.ts`: Changed the `content-type` fallback from `"text/html"` to `"application/octet-stream"` for API route responses (line 894). - `tests/fixtures/pages-basic/pages/api/no-content-type.ts`: New fixture API route that returns a response without setting Content-Type. - `tests/pages-router.test.ts`: New test verifying the API route content-type default is not `text/html`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:39:50 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#444
No description provided.