I have made a little Angular application, I have built it on my computer, but when I try to open the index.html file I have 404 errors, I tried to deploy it on a web server but it's the same :
GET http://www.valhatech.com/runtime-es2015.edb2fcf2778e7bf1d426.js net::ERR_ABORTED 404 (Not Found)
GET http://www.valhatech.com/styles.365933d9cb35ac99c497.css net::ERR_ABORTED 404 (Not Found)
GET http://www.valhatech.com/polyfills-es2015.2987770fde9daa1d8a2e.js net::ERR_ABORTED 404 (Not Found)
My index.html file is that :
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>McKenzieEquation</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script src="assets/js/app.js"></script>
</head>
<body>
<app-root></app-root>
</body>
</html>
And the content of my app.module.ts is :
const routes: Routes = [
{ path: 'home', component: AppComponent },
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: '**', redirectTo: 'home' }
];
@NgModule({
declarations: [
AppComponent,
MckenzieGraphComponent
],
imports: [
BrowserModule,FormsModule,RouterModule.forRoot(routes, { useHash: true })
],
providers: [MckenzieEquationService],
bootstrap: [AppComponent]
})
export class AppModule { }
Firefox console send me on a Reason: CORS request not HTTP error or URI of module source is not authorized in this document : « file:///polyfills-es2015.2987770fde9daa1d8a2e.js ».
I have found my error. On my web server my angular page was located to the following path : /www/mckenzieequation
And my index file was written like that :
<head>
<meta charset="utf-8">
<title>McKenzieEquation</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<script src="assets/js/app.js"></script>
</head>
I have to replace the base parameter with the following code :
<base href="/mckenzieequation/">
The base href must pointing to the place of the index file.
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