Frequently asked questions about Angular Site Template

replaceState error on ng build

If you are getting the following error when building your app you need to make sure that the BASE_URL constant is set correctly.

SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL cannot be created in a document with origin 'null' and URL

Go to src/environments/environment.prod.ts or to src/environments/environment.ts, depending if you are building for dev or for prod environments and set the BASE_URL const to the url where you are deploying your app.

For example, for development you will build your app in 4200 so BASE_URL should be set to: BASE_URL: 'http://localhost:4200'. For production environment, you can set it to your final url like: BASE_URL: 'https://your-website.com'.

BASE_URL was removed in version 2.0.0 of the template

Last updated