I am going to develop a simple Angular 2 application. I created a routing project using the Angular CLI and adding several components to the application using the "ng generate component" command. Then I specified the routing in app-routing.module.ts as follows.
import {NgModule} from '@ angular / core'; import {Routes, RouterModule} from '@ angular / router'; import {HomeComponent} from './home/home.component'; import {AboutComponent} from './about/about.component'; import {UserComponent} from './user/user.component'; import {ErrorComponent} from './error/error.component'; import {SpecialpageComponent} from './specialpage/specialpage.component'; const routes: Routes = [{path: '', component: HomeComponent}, {path: 'about', component: AboutComponent}, {path: 'user', component: UserComponent}, {path: 'specialpage', component: SpecialpageComponent}, {path: '**', component: ErrorComponent}]; @NgModule ({imports: [RouterModule.forRoot (routes)], exports: [RouterModule], providers: []}) export class AppRoutingModule {} app.module.ts is as follows.
import {BrowserModule} from '@ angular / platform-browser';
import {NgModule} from '@ angular / core';
import {FormsModule} from '@ angular / forms';
import {HttpModule} from '@ angular / http';
import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
import {HomeComponent} from './home/home.component';
import {AboutComponent} from './about/about.component';
import {ErrorComponent} from './error/error.component';
import {UserComponent} from './user/user.component';
import {SpecialpageComponent} from './specialpage/specialpage.component';
@NgModule ({
declarations: [
AppComponent
HomeComponent,
AboutComponent,
ErrorComponent,
UserComponent
Specialpagecompponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
I have not added any changes to other components. Then I deployed the application using the "ng serve" command, and the application works fine with links. For example: http: // localhost: 4200 / about

But when I deploy the project to the http server, the links do not work as expected. I deployed the application using the command "http-server./dist" and the application is perfectly deployed, but the links do not work. When I go to http: // localhost: 4200 / about ', it gives a 404 error.

Am I doing something wrong? Why does "ng-serve" work and "http-server" does not work?
Any help would be greatly appreciated. Thank you in advance.
I uploaded my project to github .