Angular 应用程序无法在 Azure 上找到资产文件

Mik*_*ike 4 azure angular

我刚刚通过运行 ng build --prod 并将其推送到 git 将我的 angular 应用程序部署到 azure,但我收到 404 错误,说它在资产文件夹中找不到我的 json 文件。

我也试过运行 ng build --prod --base-href "./" 但我一直遇到同样的错误。

我目前正在尝试在这样的 api 服务中获取文件:

return this.http.get('../assets/exercises.json')
Run Code Online (Sandbox Code Playgroud)

但是当我在 azure 上运行网站时,我收到了 404 错误 Failed to load resource: the server responded with a status of 404 (Not Found)

Saj*_*ran 8

你需要在Angular的文档中添加你自己的web.config.Its:https : //angular.io/guide/deployment

<staticContent><mimeMap fileExtension=".json" mimeType="application/json" /></staticContent>
Run Code Online (Sandbox Code Playgroud)

  • /sf/ask/3230020321/ (2认同)