angular - Angular 应用无法在 Azure 上找到资产文件
问题描述
我刚刚通过运行 ng build --prod 并将其推送到 git 将我的 Angular 应用程序部署到 azure,但我收到 404 错误,说它无法在 assets 文件夹中找到我的 json 文件。
我也尝试过运行 ng build --prod --base-href "./" 但直到遇到同样的错误。
我目前正在尝试在这样的 api 服务中获取文件:
return this.http.get('../assets/exercises.json')
但是当我在 azure 上运行网站时出现 404 错误
Failed to load resource: the server responded with a status of 404 (Not Found)
解决方案
您需要在 Angular 的文档中添加自己的 web.config.Its:https ://angular.io/guide/deployment
<staticContent><mimeMap fileExtension=".json" mimeType="application/json" /></staticContent>
推荐阅读
- vba - 当数据为数千时,我的对帐 VBA 宏运行时间过长
- python - Pandas 填充列中的某些值
- ios - UITableView + UICollectionView + UITableView 大小问题
- azure-devops - Azure DevOps 卡没有 Github 注释或测试
- javascript - React Redux:在调度之前调用使用 Selector
- amazon-web-services - 从 Appsync 连接到 ElasticSearch/OpenSearch 数据源时出现“Elasticsearch 响应错误:禁止”
- javascript - 提示不从客户端获取用户输入
- pgadmin-4 - 如何为 PostgreSQL 14 设置 PostgreSQL 二进制路径
- amazon-s3 - s3cmd mb 失败,访问 ID 错误,而 s3cmd rb 成功
- angular - 在角度材料下拉列表中显示预选值