I am facing this issue across all browsers. This comes up whenever I try to view my site in Google cache
main.bundle.js:1 ERROR Error: Uncaught (in promise): SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'https://mydomainn.com/' cannot be created in a document with origin 'http://webcache.googleusercontent.com'
. The same problem lies with express google. http://webcache.googleusercontent.com/search?q=cache%3Ahttps%3A%2F%2Fexpress.google.com%2Fstores&oq=cache%3Ahttps%3A%2F%2Fexpress.google.com%2Fstores&aqs=chrome..69i57j69i58.3999j0j4&sourceid=chrome&ie=UTF-8.
My base href is /
In your routes configuration add
RouterModule.forRoot(routes, {useHash: true});
In your index.html do this;
<!-- <base href="/"> -->
<script>document.write('<base href="' + document.location + '" />');</script>
And then build with --base-href ./ e.g
ng build --prod --base-href ./
source https://github.com/angular/angular/issues/13948
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With