mime-type
它能做什么
这项技能检查服务器随 HTML、CSS、JavaScript、图片和字体一起发送的内容类型标头。适用于管理 Web 服务器或排查页面资源故障的人。
适用场景
- ✓当你请智能体检查服务器是否发送了正确的文件类型的时候。
- ✓当样式表或脚本无法加载,而你怀疑内容类型有误的时候。
- ✓当你设置新的托管或新框架,并想确认其标头正确的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/mime-type/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我网站上的 CSS 没有加载。请帮我检查服务器是否发送了正确的内容类型?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查关键页面和链接文件的响应标头,并与预期类型(例如样式表的 text/css)进行比较。如果不匹配,它会建议修改服务器设置。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
MIME Type Validation
Incorrect MIME types cause browsers to block stylesheets and scripts (MIME sniffing is disabled by X-Content-Type-Options: nosniff), breaking page rendering and signalling poor site quality to crawlers.
Quick Reference
- The Content-Type header must match the actual file type being served
- HTML pages must be served as text/html; charset=utf-8
- CSS files must be served as text/css and JavaScript as text/javascript
- Incorrect MIME types cause browsers to block or mishandle resources
Check
For key pages and their linked resources, inspect the HTTP Content-Type response header. Verify HTML responses use text/html; charset=utf-8, CSS uses text/css, JS uses text/javascript, and images use image/jpeg, image/png, etc.
Fix
Update your server configuration to serve each file type with its correct MIME type. Set X-Content-Type-Options: nosniff to prevent browsers from guessing content types. In Next.js and similar frameworks, configure headers in next.config.js.
Explain
The Content-Type header tells browsers and crawlers what kind of content is being sent. When it mismatches the actual file type, browsers either block the resource or render it incorrectly—CSS served as text/plain won't be applied, and JavaScript served as text/html may be blocked by strict MIME checking.
Code Review
For HTML, CSS, and JS assets, check the Content-Type response header. Verify HTML responses include 'charset=utf-8'. Check that X-Content-Type-Options: nosniff is set. Flag any resource returning Content-Type: text/html that is not an HTML page. Check for missing charset declarations on text responses.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
常见问题
内容类型错误会怎样?
浏览器可能会阻止该文件,或错误地显示它,因此样式表可能完全无法生效。
nosniff 是做什么的?
X-Content-Type-Options 标头告诉浏览器不要猜测类型,而是依据服务器发送的值。
在 Next.js 中如何设置?
这项技能建议在 next.config.js 文件中配置标头。
详情
作者的原始描述
Use when auditing server configuration or diagnosing broken resources. Applies to any web server serving HTML, CSS, JS, images, fonts, or other static assets.
热度
- GitHub 星标
- 75k
- 排名
- #2938
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。