gpt4 book ai didi

css - 在 Azure 中获取 .css 文件时出错

转载 作者:太空宇宙 更新时间:2023-11-04 09:27:01 25 4
gpt4 key购买 nike

我在 Azure 上有一个 nodejs 应用程序(作为网络应用程序安装),我在尝试获取样式表 (.css) 时收到以下消息:

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

我有read that the problem is an IIS config所以我的问题是:

  1. 这真的是 IIS 问题吗?
  2. 如果是,我该如何在 Azure 中修复它?

最佳答案

根据我的经验,我认为这不是 IIS 问题。看来您正在以自己的方式提供静态文件。在 Azure Web Apps 中,我们不需要这样做,如果您查看 web.config 文件中的以下几行,您会发现 IIS 服务器已经处理了从 /public 目录。所以我们可以在元素的根目录下添加一个名为public的文件夹,然后把静态文件放在那里。

<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>

例如,元素结构如下所示, enter image description here

如果您使用 Express ,你也可以用下面的代码做同样的事情,

app.use(express.static('public'))

关于css - 在 Azure 中获取 .css 文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41018526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com