【问题标题】:GAE: Resource interpreted as Stylesheet but transferred with MIME type text/htmlGAE:资源解释为样式表,但使用 MIME 类型 text/html 传输
【发布时间】:2011-12-13 00:28:48
【问题描述】:
我有一个 Google App Engine 网站,当我使用 javascript 加载样式表 (editor.css) 时,样式未应用于 html,我收到此错误:
Resource interpreted as Stylesheet but transferred with MIME type text/html.
我在 HTML 中声明的样式表不会发出此警告...只有通过 iframe 中的 javascript 调用的样式表。我该如何调试?
【问题讨论】:
标签:
google-app-engine
mime-types
【解决方案1】:
可以通过在您的应用引擎应用程序的app.yaml 中设置 Mime 类型配置来解决该问题。
application: your application name
version: 1
runtime: php
api_version: 1
handlers:
- url: /stylesheets
mime_type: 'text/css'
static_dir: stylesheets
- url: .*
script: helloworld.php
确保 CSS 文件保存在 stylesheets 文件夹中或将 static_dir 文件夹重命名为您的 CSS 文件夹。
【解决方案2】:
您的应用正在发送 mimetype 为“text/html”而不是“text/css”的 css 文件。使用浏览器的开发工具来验证这一点(查找对 CSS 文件的请求并检查响应标头。
如果文件由应用程序代码提供,请确保您发送正确的 mimetype。如果它作为静态文件提供,您可以将 mimetype 设置为记录的here。