Reputation: 8661
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);
Upvotes: 0
Views: 115
Reputation: 8661
The problem was caused by me unknowingly changing from the HashLocationStrategy to the PathLocationStrategy
Upvotes: 0
Reputation: 5435
If you use Node.js, then you have to redirect all to index.html file.
app.use('*', function(req, res) {
res.render('index.html');
});
Don't know if res.render
or res.redirect
(it is not important though, I just gave you the idea).
by the way, try to edit
redirectTo: '/browse'
to redirectTo: 'browse'
Upvotes: 0