无法在 https 服务器中下载 json 数据,同样在本地工作正常

Not able to download the json data in https server, same works fine in local

我正在使用 "assets" 文件夹中的静态数据,通过这样导入:

import programmeManagment from './../../../assets/mock-json/programme-management.json';

并在服务中使用:

return of(JSON.parse(JSON.stringify(programmeManagment)));

它在本地主机上运行良好。当我将代码移至服务器时,它显示错误为:

https:xxx.azurewebsites.net/assets/mock-json/programme-management.json 404 Not Found 响应显示为:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

这是怎么想出来的?

这样试试:

this.http.get('./../../../assets/mock-json/programme-management.json').subscribe( res => {
    console.log(res)
})

请检查文件程序-management.json 在您的托管位置是否可用。

如果没有,请尝试更改文件名中的特殊字符。

而不是

节目-management.json.

使用这个,

计划management.json

我在 prashath 的建议下解决了问题。分享给他人使用。 从这里得到答案:

 "assets": [
      "src/assets",
      "src/favicon.ico",
      "src/web.config" <---- Removed this line
    ],