【问题标题】:Changing MIME type with Meteor使用 Meteor 更改 MIME 类型
【发布时间】:2016-09-08 21:38:39
【问题描述】:

当我在 localhost 上运行我的应用程序时,我收到 2 条关于 MIME 类型的警告。这是其中之一:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:3000/BootstrapEssentials/bootstrap.css".

另一个警告与不同的文件相同。这两个文件都在我的工作目录中。到目前为止,我遇到过这些类似的问题,但它们没有帮助:

Resource interpreted as stylesheet but transferred with MIME type text/html (seems not related with web server)

Chrome says "Resource interpreted as script but transferred with MIME type text/plain.", what gives?

Resource interpreted as stylesheet but transferred with MIME type text/html

最初我试图使用这一行:

<link rel="stylesheet" href="/BootstrapEssentials/bootstrap.css">

我已经在类型字段中添加了:

<link rel="stylesheet" href="/BootstrapEssentials/bootstrap.css" type="text/css">

但这并没有做任何事情。我还使用 JavaScript 控制台看到它在响应标头中具有 content-type: text/html; charset=utf-8,我相信如果我可以将其更改为 content-type: text/css; charset=utf-8,那么一切都会好起来的,但我也找不到如何做到这一点。

【问题讨论】:

  • BootstrapEssentials 文件夹是否位于名为 public 的目录中?
  • @sheeldotme 不,应该是吗?我目前将它放在我的 client.js 文件旁边的 clients 文件夹中。

标签: css meteor mime


【解决方案1】:

根据 Meteor 文档:

名为 public/ 的顶级目录中的所有文件都按原样提供给客户端。引用这些资产时,不要在 URL 中包含 public/,将 URL 写成好像它们都在顶层一样。例如,将 public/bg.png 引用为 /bg.png。这是存放 favicon.ico、robots.txt 和类似文件的最佳位置。

将您的样式表移至公共目录应该可以解决问题!

【讨论】:

    猜你喜欢
    • 2014-09-20
    • 2015-03-10
    • 1970-01-01
    • 1970-01-01
    • 2012-08-22
    • 2012-11-02
    • 2012-12-07
    • 2011-09-19
    • 1970-01-01
    相关资源
    最近更新 更多