nextjs - ✅(Solved) Fix [Bug] Content-Type text/x-component does not have charset=utf-8 encoding [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#91942Fetched 2026-04-08 01:35:37
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
cross-referenced ×1issue_type_added ×1labeled ×1referenced ×1

Root Cause

I would expect that the server actions will return a correct encoding as other text based responses. This cannot be patched in proxy because the content type header is set after the proxy.

Fix Action

Fix / Workaround

I would expect that the server actions will return a correct encoding as other text based responses. This cannot be patched in proxy because the content type header is set after the proxy.

PR fix notes

PR #91957: fix(rsc): add charset=utf-8 to text/x-component Content-Type header

Description (problem / solution / changelog)

What

RSC flight responses were missing the charset=utf-8 encoding declaration in their Content-Type header. HTML responses use text/html; charset=utf-8 and JSON responses use application/json, but RSC responses only set text/x-component — making it impossible for proxies and middleware to reliably patch the Content-Type downstream.

Why

The RSC_CONTENT_TYPE_HEADER constant is used for two different purposes:

  1. Setting the response Content-Type header (server-side)
  2. Detecting RSC responses via startsWith() on incoming headers (client-side)

These had conflicting requirements — the set value needs ; charset=utf-8, but the detection pattern should match the base MIME type to handle both old and new cached responses.

How

  • Add RSC_CONTENT_TYPE_HEADER_FULL = 'text/x-component; charset=utf-8' for use when setting response headers
  • Use RSC_CONTENT_TYPE_HEADER_FULL in FlightRenderResult and RenderResult.fromStatic() calls that set the Content-Type response header
  • Keep RSC_CONTENT_TYPE_HEADER = 'text/x-component' for client-side detection and routes manifest (infra compatibility)
  • Update the cached contentType comparison to startsWith() to handle both old cached values (without charset) and new ones (with charset)

Fixes #91942

Changed files

  • packages/next/src/build/templates/app-page.ts (modified, +4/-3)
  • packages/next/src/client/components/app-router-headers.ts (modified, +2/-0)
  • packages/next/src/server/app-render/flight-render-result.ts (modified, +3/-3)
  • packages/next/src/server/render-result.ts (modified, +3/-2)

Code Example

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Enterprise
  Available memory (MB): 65202
  Available CPU cores: 20
Binaries:
  Node: 24.4.0
  npm: 11.4.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.1.5 // No Next.js version data was found.
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: standalone
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template

To Reproduce

  1. start next.js server
  2. invoke server action
  3. inspect the response headers
  4. content-type=text/x-component won't have charset=utf-8 encoding
<img width="636" height="119" alt="Image" src="https://github.com/user-attachments/assets/bf3de252-28b0-40e3-93cc-c7e10b20fa0b" />

Current vs. Expected behavior

I would expect that the server actions will return a correct encoding as other text based responses. This cannot be patched in proxy because the content type header is set after the proxy.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Enterprise
  Available memory (MB): 65202
  Available CPU cores: 20
Binaries:
  Node: 24.4.0
  npm: 11.4.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.1.5 // No Next.js version data was found.
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: standalone

Which area(s) are affected? (Select all that apply)

Server Actions

Which stage(s) are affected? (Select all that apply)

Other (Deployed)

Additional context

I'm willing to send a PR if you confirm that this should be fixed.

extent analysis

Fix Plan

To fix the issue of missing charset=utf-8 encoding in the Content-Type header for server actions, you can manually set the header in your Next.js server action.

Here are the steps:

  • Identify the server action that is returning the text/x-component content type.
  • Set the Content-Type header with the charset=utf-8 parameter.

Example code:

import { NextApiRequest, NextApiResponse } from 'next';

const serverAction = async (req: NextApiRequest, res: NextApiResponse) => {
  // Your server action code here

  // Set the Content-Type header with charset=utf-8
  res.setHeader('Content-Type', 'text/x-component; charset=utf-8');

  // Return the response
  res.status(200).send('Your response data');
};

export default serverAction;

Verification

To verify that the fix worked, you can inspect the response headers of the server action using your browser's developer tools or a tool like curl. The Content-Type header should now include the charset=utf-8 parameter.

Example curl command:

curl -I https://your-domain.com/server-action

Look for the Content-Type header in the response:

Content-Type: text/x-component; charset=utf-8

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING