I am facing an issue with setting up html5 mode in angular along with node.js where the fallback to hash does not work for routes more than 1 level deep on browsers that do not support html5 mode.
Here is my server route to catch all:
app.all('/*', function(req, res) {
console.log('serve');
res.sendFile(__dirname+'/public/index.html');
});
To address this problem, I have added a base tag right after the opening head tag.
<base href="/">
When attempting to visit a URL like 'localhost/news'
In supported browsers, the site loads at the same URL and hits the server once, logging 'serve'. However, for non-supported browsers, it changes the URL to localhost/#/news which is ideal.
Now, if the URL is localhost/news/post1, supported browsers still work fine. But on non-supported browsers, it loads the index.html file without any styles or JS, hitting the server multiple times and causing over 50+ log entries for 'serve'. The URL remains unchanged and the page remains broken.
The browser I tested against was IE9. Does anyone know of a solution to this issue?