I'm developing a Progressive Web App (PWA) using Angular. Everything was functioning smoothly until out of nowhere, I started encountering a 404 Error whenever I tried to navigate to a new component while serving in dist/project with http-server. Surprisingly, I haven't made any changes to the code since deploying it on git
Despite trying various troubleshooting steps like reinstalling Visual Studio, rebooting my computer, updating the Service Worker in the Ctrl+Shift+i menu, and resetting in git, the issue persists.
Below is my Angular routing module:
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 { }
Index.html
<head>
<meta charset="utf-8">
<title>FbIhi</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#1976d2">
<link href = "https://fonts.googleapis.com/css?family=Monteserrat" rel="stylesheet">
</head>
<body>
<app-root></app-root>
manifest.json
{
"name": "fb-ihi",
"short_name": "fb-ihi",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "/",
"start_url": "/",
"icons": [
{
"src": "assets/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "assets/icons/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "assets/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "assets/icons/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "assets/icons/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "assets/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "assets/icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "assets/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
and ngsw-config.json
{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/*.css",
"/*.js"
],
"urls":[
"htts://fonts.googleapis.com/**"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}],
"dataGroups": [
{
"name":"jokes-api",
"urls": ["https://api.chucknorris.io/jokes/random"],
"cacheConfig":{
"strategy": "freshness",
"maxSize": 20,
"maxAge": "90d",
"timeout":"5s"
}
}
]
}
My expectation is to seamlessly navigate to the next component by clicking a button in the app. However, instead, an error stating "Not Found" keeps appearing.