angular - Routing behing nginx -
i have angular2 application. works fine, if using local webpack dev server.
when deploy application on server behind nginx i can navigate using application links. if i enter url browser url bar get 404 not found error.
here nginx config 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 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 not sure nginx configuration error, or application error. how can fix ?
i have solved problem adding usehash router:
routermodule.forroot(approutes, { usehash: true }),
Comments
Post a Comment