After successfully building my Angular Application using ng build --prod and serving it with http-server -o, I encountered a sudden issue. Now, every time my app tries to load a new component, I receive a 404 error.
I have attempted various solutions such as restarting my computer, rebuilding the application, reverting back to previous git commits that were functional, and updating the service worker. Unfortunately, none of these attempts have resolved the problem.
const appRoutes: Routes=[
{path: '', component: HomeComponent},
{path: 'home', component: HomeComponent},
{path: 'whoconebioassayphase1', component: WhoConeBioassayPhase1Component},
{path: 'editwhoconebioassayphase1', component: Editwhoconebioassayphase1Component},
{path: 'exphutintro', component: ExpHutIntroComponent},
{path: 'exphut', component: ExpHutComponent},
{path: 'editexphutintro', component: EditexphutintroComponent}
]
@NgModule({
declarations: [
AppComponent,
WhoConeBioassayPhase1Component,
NavbarComponent,
HomeComponent,
Editwhoconebioassayphase1Component,
ExpHutIntroComponent,
ExpHutComponent,
EditexphutintroComponent,
],
imports: [
BrowserModule,
RouterModule.forRoot(appRoutes),
HttpClientModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
FormsModule,
ReactiveFormsModule,
AngularFireModule.initializeApp(environment.firebase),
AngularFirestoreModule
],
providers: [DataService],
bootstrap: [AppComponent]
})
export class AppModule { }