I have an angular2 application. All works fine, if I using local webpack dev server
.
When I deploy application on the server behind nginx
I can navigate using application links. But if I enter URL to browser URL bar I get 404 Not Found
error.
Here is an Nginx config for site:
server {
listen 80;
server_name mydomain;
location /api {
proxy_pass http://mydomain:4000;
}
location /token-auth {
proxy_pass http://mydomain:4000;
}
location / {
root /www;
}
}
Here is my application details:
<base href="/">
@NgModule({
imports: [
RouterModule.forRoot(appRoutes),
export const appRoutes:Routes = [
{ path: 'login', component: LoginComponent },
{ path: 'rss', component: RssComponent, data: { section: 1 }, canActivate: [AuthGuard] },
{ path: '', redirectTo: '/login', pathMatch: 'full' }
];
@Component({
selector: 'my-app',
template: `
<div id="application">
<app-navigation-tabs></app-navigation-tabs>
</div>
<div>
<router-outlet></router-outlet>
</div>
`,
styleUrls: ['app.component.css']
})
<ul class="nav nav-tabs">
<li role="presentation" [ngClass]="{active: currentSection === 3}"><a [routerLink]="['/rss']" (click)="toggleSection(3)">RSS</a></li>
I am not sure it is Nginx configuration error, or it is my application error. How can I fix it ?