How do I stop Angular2 router appending the same route twice when i refresh the page? It might be something other than angular router.
Go to the root of the app it redirects contact, which is good.
localhost:3000/contact
Refresh the page and it appends the same route
localhost:3000/contact/contact
the express server only contains 2 routes handlers. Return static files and for everything else return the index.html file.
app.get(/\.\w{2,4}$/, function (req, res) {
res.sendFile(path.join(__dirname, req.url));
});
app.get('*', function (req, res) {
res.sendFile(path.join(__dirname, 'index.html'));
});
index.html has base href set
<base href="/">
This is the angular route config
export const routes: Routes = [
{path: '', redirectTo: 'contact', pathMatch: 'full'}
]
HashLocationStrategy
? – Günter Zöchbauer