Angular 8:生产环境无法加载图像。给出403错误,因为相对网址路径被附加到资产/图片路径中]] << [

问题描述 投票:-1回答:1
我在本地环境中的Angular应用程序能够加载图像,但是在通过AWS代码构建在生产环境中部署后,它出现403错误。

以下是构建命令:ng build --configuration = qa --aot = false --base-href =

以下是错误:Error on fetching images

尽管,如果我只是尝试从浏览图像:https://mfqa.credivia.com/assets/images/logo.png而不是https://mfqa.credivia.com/borrower/assets/images/logo.png,图像被加载。

问题:尝试检索图像时,将添加相对URL路径。

已检查:

    Dist文件夹在根目录中包含[assets]文件夹
  1. base href =“ /”
  2. 提供的图像路径为:img src =“ assets / images / loading.gif”
  3. 以下是来自angular.json的代码段:

"root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.app.json", "aot": false, "assets": [ "src/favicon.ico", "src/assets" ],
我在本地环境中的Angular应用程序能够加载图像,但是在通过AWS代码构建在生产环境中部署后,它显示403错误。以下是构建命令:ng build --configuration = qa --...
angular angular-cli production-environment
1个回答
0
投票
感谢您的回复。问题是在prod build命令中设置--base-href时。
© www.soinside.com 2019 - 2024. All rights reserved.