title: Handling Single Page App url routing
body: <p>I want to have all requests return the index.html page which contains the front end app that will handle its own routing. Also I want that css/html/images/js are returned correctly so not to return index.html for all of these. So I have somthing like that in the server.js</p>
  
  <pre><code>var express = require('express');
  var app = express();
  var path = require("path");
  
  
  app.use(express.static(path.join(__dirname,"app")));
  app.get('*', function(req, res) {
      console.log(res);
      res.sendFile(path.join(__dirname, 'app', 'index.html')); // load the single view file (angular will handle the page changes on the front-end)
  });
  
  
  app.listen(5000);
  </code></pre>
  
  <p>Now If I type <code>localhost:5000</code> I can get all the resources and every thing is okay. But if I make <code>localhost:5000/something</code> every resource I guess isn't found by <code>express.static</code> and is handled by the <code>app.get(*,...)</code> so all resources are returned as index.html.</p>
  
  <p>So how can I have this kind of setup to work?!</p>