I built a website using Angular. I'm a fairly basic Angular user, but my application is in a state that I am currently happy with. Throughout development I always used ng serve to test and debug my application.
The dist compiles successfully on ng build and with ng build --prod>. Running ng serve --prod works just fine too. However, when I try to open the application through the index.html page in the dist folder (using the -- bh . flag when building, I get one of two very similar errors)
Error: Uncaught (in promise): SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///C:/Users/quent/website/PersonalWebApp/dist/' cannot be created in a document with origin 'null' and URL 'file:///C:/Users/quent/website/PersonalWebApp/dist/index.html'. Error: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///C:/Users/quent/website/PersonalWebApp/dist/' cannot be created in a document with origin 'null' and URL 'file:///C:/Users/quent/website/PersonalWebApp/dist/index.html'.
There is also one error where the page cannot correctly get an image
Failed to load resource: net::ERR_FILE_NOT_FOUND
So, this leads me to believe that this is an Angular issue I am having and not a deployment issue. For reference, when I try to deploy to Azure, I get a Failed to load resource: the server error in the console and am presented with presented with Cannot GET / on the page.
I included my angular-cli.json file for reference. If this is not enough information to help me start debugging this issue please let me know. Thanks much!
My .angular-cli.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "personal-web-app"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico",
"web.config"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.scss"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/hammerjs/hammer.min.js",
"../node_modules/tether/dist/js/tether.js",
"../node_modules/bootstrap/dist/js/bootstrap.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"component": {}
}
}