angular icon indicating copy to clipboard operation
angular copied to clipboard

How to serve application Assets from cdn in Angular

Open zanul-siddiqui-au3 opened this issue 1 year ago • 1 comments

Which @angular/* package(s) are the source of the bug?

platform-browser-dynamic, platform-browser, router

Is this a regression?

Yes

Description

We want to serve our application from cdn all bundles and assets(images , icons , fonts etc.) but the problem is when we are using --deploy-url flag during build it only fetch bundle files (main.js etc) from cdn but still all assets are coming from server but when use --base-href flag it thrown these error Unhandled Navigation Error: SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL and application is not getting loaded and we didn't want to use hash strategy for our application is there any way we can server all assets from cdn ?

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

Unhandled Navigation Error: SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 13.3.9
Node: 16.15.0
Package Manager: npm 8.5.5
OS: win32 x64

Angular: 13.3.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1303.9
@angular-devkit/build-angular      13.3.9
@angular-devkit/core               13.3.9
@angular-devkit/schematics         13.3.9
@angular/cdk                       13.3.9
@angular/cli                       13.3.9
@angular/localize                  14.2.0
@angular/material                  13.3.9
@angular/material-moment-adapter   13.3.9
@schematics/angular                13.3.9
rxjs                               6.6.7
typescript                         4.6.4

Anything else?

No response

zanul-siddiqui-au3 avatar Sep 14 '22 06:09 zanul-siddiqui-au3

This issue is still missing relevant details for us to understand the problem you're experiencing, and what the cause of this issue might be. Please provide a minimal reproduction if you think this is an Angular bug; for support questions I'd request that you'll ask on platforms such as StackOverflow instead of the issue tracker here.

JoostK avatar Sep 14 '22 07:09 JoostK

This is somewhat described in https://angular.io/guide/deployment#the-deploy-url.

The base href can also be used to define the Angular router's default base (see APP_BASE_HREF). Users with more complicated setups may need to manually configure the APP_BASE_HREF token within the application (for example, application routing base is / but assets/scripts/etc. are at /assets/).

That is, it sounds like you want to use <base href="..." /> in your index.html and also want to provide a different APP_BASE_HREF for routing purposes.

In addition this issue doesn't fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag angular.

If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation.

atscott avatar Sep 19 '22 16:09 atscott

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.