I have deployed an angular application with lazy loading. The application works perfectly when hosted on Github.io domain but I am getting an error when I deployed the app on tomcat server using mobaxterm. When the page reloads or refreshes the app loses the routing state and throws a 404 error.
HTTP Status 404 - /enquiry
type Status report
message /enquiry
description The requested resource is not available.
Apache Tomcat/7.0.72
Console-Log:: GET http://appv2.proctur.com/enquiry/addEnquiry 404 (Not Found) Navigated to http://appv2.proctur.com/enquiry/addEnquiry
If I do not refresh the page and use the app in one go then its OK, just fail to understand what the issue is on refresh.
PS:: this is my first time hosting an angular application on tomcat server if I made any silly mistake please let me know.
For better clarification, I am adding the routing.module.ts where I lazy load the modules. This is imported into app.module.ts::
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
@NgModule({
imports: [
RouterModule.forRoot([
{ path: '', redirectTo: '/authPage', pathMatch: 'full' },
{ path: 'authPage', loadChildren: 'app/components/auth-page/auth-page.module#AuthPageModule' },
{ path: 'course', loadChildren: 'app/components/course/course.module#CourseModule' },
{ path: 'enquiry', loadChildren: 'app/components/enquiry/enquiry.module#EnquiryModule' },
{ path: 'student', loadChildren: 'app/components/students/student.module#StudentModule' },
])
],
exports: [
RouterModule
]
})
export class AppRoutingModule {
}