gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 02:06:04 26 4
gpt4 key购买 nike

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

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

我目前正在尝试在 api 服务中获取文件,如下所示:

return this.http.get('../assets/exercises.json')

但是当我在 azure 上运行该网站时,出现 404 错误无法加载资源:服务器响应状态为 404(未找到)

最佳答案

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

<staticContent><mimeMap fileExtension=".json" mimeType="application/json" /></staticContent>

关于Angular 应用程序无法在 Azure 上找到 Assets 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56213819/

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