7

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 ».

3 Answers 3

21

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I am experiencing the same issue after I have upgraded from Angular 12 -> 13. And I already have set my base href in index.html to the correct path. For some reason it just stopped working after I upgraded Angular :(
0

For me the issue was that app-root wasn't inside body tag

Comments

0

I just had this issue after updating to Angular 17.1.1. I switched back to 17.0.5 and main.js, polyfill.js, etc were again properly served when running ng serve.

3 Comments

Did you find a way to upgrade back to 17.1.x? I'm dependant on 17.1.x because of a library
Sorry, I'm on Angular 19 now.
That's alright. I mentioned before I would add an answer with my solution, but actually I won't. Turns out the issue was only happening on localhost for me, so what I did was to set outputHashing to none in the local config and outputHashing to all in the production config. This solved the issue for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.