How to serve application Assets from cdn in Angular

This issue has been tracked since 2022-09-14.

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

JoostK wrote this answer on 2022-09-14

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.

atscott wrote this answer on 2022-09-21

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.

More Details About Repo
Owner Name angular
Repo Name angular
Full Name angular/angular
Language TypeScript
Created Date 2014-09-18
Updated Date 2022-10-05
Star Count 84147
Watcher Count 3063
Fork Count 22247
Issue Count 1201

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date