Node.js / Expess.js. Static router not recognized if used with wildcard router
express, javascript, node.js
Solution
There is nothing wrong with your code but keep in mind that any request on something that doesn't exist will be catch by your get('/*', ...).
This said, you load `public_dir` on `/public` that's mean if `public_dir` is defined as `public/website/` you have to do `http://127.0.0.1:3000/public/application.js` in order to access a file locate at `/public/website/application.js`
Problem
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.