When I use only this route with my all other routes, that static files served well:
var public_dir = path.join(__dirname, 'public');
app.use('/public', express.static(public_dir));
But when I add below these lines - all requests are catch with this router (not the previous one):
app.get('/*', function(req, res){
res.redirect('/#!' + req.path);
});
It's strange to me, because /public definition comes first. But all request goes to last defined /* request handler.
Now, if I try to open page http://127.0.0.1:3000/public/website/application.js I become redirected to http://127.0.0.1:3000/#!/public/website/application.js. Why it happens, and how to solve this situation in the best manner?
Thank you a lot!
Solution is simple. I have not working statement in list of middlewares.
app.use(app.router);
This is creates a problem of url routing. But it's strange that node.js did not tell me about "incorrect setup" of middleware.