fix: add charset=utf-8 to .txt responses via _headers - #908
Merged
Merged
Conversation
Cloudflare Workers Static Assets serves llms.txt, llms-full.txt and llms-small.txt with a bare `text/plain` Content-Type in production, while `wrangler dev` adds `charset=utf-8` locally. The files contain non-ASCII content (emoji, CJK), so clients that default to ISO-8859-1 render mojibake. Add a `_headers` rule so both match.
Member
|
This fix is meaningful. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
https://hono.dev/llms.txt(andllms-full.txt/llms-small.txt) is served in production with a bareContent-Type: text/plain, whilewrangler devreturnstext/plain; charset=utf-8locally.The difference comes from wrangler: its local asset server appends
charset=utf-8to everytext/*type, but the production Static Assets service only maps the extension totext/plain. Since these files contain non-ASCII content (🔥, CJK), clients that fall back to ISO-8859-1 show mojibake.Fix
Add
public/_headerswith a rule for*.txt:public/is copied verbatim into.vitepress/dist, so the file ships with the normal build and is picked up by Workers Static Assets.Verification
Ran
wrangler devagainst the builtdistwith this file included:Note: after deploy, the Cloudflare edge cache (
cf-cache-status: HIT) may need to expire or be purged before the new header shows up.🤖 Generated with Claude Code