Meteor资源被解释为样式表,但传输的MIME类型为text/html。

3

我正在使用Meteor,我的静态文件位于public目录中:

// Directory Structure

app
    app/.meteor
    app/server
    app/client
    app/packages
    app/lib
    app/public
        app/public/styles
        app/public/images

在我的index.html文件中,我有这样一段代码:

<link rel="stylesheet" href="/public/styles/app.css"/>

我仍然收到以下错误信息:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:3000/public/styles/app.css"

我该如何解决这个问题?meteor公共目录的正确使用方法是什么?

1个回答

7

您请求的目录不正确。Meteor会像处理任何未指向文件的路径一样提供HTML。

URL路径应该指向:

<link rel="stylesheet" href="/styles/app.css"/>

public目录下的所有内容都应该映射到/


我的样式表在<link href="/client/stylesheets/bootstrap.css" rel="stylesheet">中,因为建议将所有样式表移动到这个结构中。我该如何消除相同的错误? - a4xrbj1
谢谢!我希望一个小时之前就看到这个了! - C.Lee

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接