Search code examples
angularangular-routingangular-rc5

Angular 2 rc.5 unable to refresh page after updating from rc.4


I have just finished updating my app from rc.4 to rc.5 and I'm encountering a weird error.

When I hit localhost:8080 I am redirected to localhost:8080/browse as expected, however when I then hit the browser refresh button I get the following error: Cannot GET /browse.

Note: Before a hash was being added to the URL, i.e. localhost:8080/#/browse but not that doesn't get added.

Here's my routes:

const routes: Routes = [
  {
    component: DashboardComponent,
    path: 'browse'
  }, {
    component: ProductViewportComponent,
    path: 'project/:id'
  }, {
    path: '',
    pathMatch: 'full',
    redirectTo: '/browse'
  }
];

export const routing: any = RouterModule.forRoot(routes);

Solution

  • The problem was caused by me unknowingly changing from the HashLocationStrategy to the PathLocationStrategy