【问题标题】:node.js website deployed to Azure - 404 failed to load a .json resource部署到 Azure 的 node.js 网站 - 404 无法加载 .json 资源
【发布时间】:2015-06-04 07:20:53
【问题描述】:

我在 Azure 中有一个 node.js Web 应用程序,

该站点加载 index.html、css、图像等,但 JS 搜索功能未初始化, 我在 Chrome 中进行了 F12 检查并看到了这个错误

[domain].azurewebsites.net/data/policies.json Failed to load resource: the server responded with a status of 404 (Not Found)

在 Azure 控制台中我可以看到文件列表

> cd public
D:\home\site\wwwroot\public

> cd data
D:\home\site\wwwroot\public\data

> ls
D:\home\site\wwwroot\public\data

policies.json

根据文件夹/文件结构(一切都在/public文件夹中)我做了如下配置更改

/ = "网站/webroot/公共"

文件夹的布局是这样的

/public/index.html
/public/data
/public/js
/public/css

如果没有配置设置,网站不会将 /public 视为根文件夹,因此找不到 index.html 并且不会加载任何内容。

所以网站加载,这很棒, 图像和 css 加载,这很棒

但它说在数据文件夹中找不到 .json 文件? (并且使用控制台,文件肯定在那里!)

请指教。

【问题讨论】:

    标签: node.js azure webserver http-status-code-404


    【解决方案1】:

    需要在 web.config 中设置 JSON MIME 类型

    此链接说明了如何修复它: http://blogs.msdn.com/b/africaapps/archive/2013/06/07/how-to-serve-static-json-files-from-a-windows-azure-website.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-26
      • 2022-01-13
      • 2017-08-18
      • 1970-01-01
      • 1970-01-01
      • 2019-02-26
      • 2021-04-17
      • 1970-01-01
      相关资源
      最近更新 更多