Repository navigation
fix(deploy): 为 Markdown 与纯文本静态资源配置 UTF-8 响应头 - #155
Merged
Merged
Conversation
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.
变更说明
问题背景
浏览器直接访问
https://docs.maibot.chat/installation-agent.md(以及llms.txt等纯文本资源)时出现中文乱码(如显示为å®‰è£…æŒ‡å —)。原因排查:
.md文件返回Content-Type: text/markdown,对.txt文件返回Content-Type: text/plain,均未携带; charset=utf-8。<meta charset="utf-8">声明,主流浏览器缺乏 charset 参数时会回退至系统或默认字符集(如windows-1252或GBK),导致多字节的 UTF-8 中文字符串解码失败产生乱码。修复方案
新增
public/_headers配置文件(VitePress 构建时会自动复制到输出根目录.vitepress/dist/_headers):/installation-agent.md、/*.md、/**/*.md明确声明Content-Type: text/markdown; charset=utf-8;/*.txt、/**/*.txt(含llms.txt、llms-full.txt)明确声明Content-Type: text/plain; charset=utf-8;Access-Control-Allow-Origin: *,便于 AI 客户端/Web Agent 跨域获取文档上下文。验证情况
pnpm docs:build验证构建通过,且.vitepress/dist/_headers正确生成;node scripts/docs-quality.mjs门禁 8 项检查全部 0 违规通过。