title: Node.js: Work with app.use & app.get together
body: <p>I have a react application rendering by my node server. I want in addition to rendering my react app, call my server as a API to recieve some data. </p>
  
  <p>How is it possible to do it ? </p>
  
  <p>Here my node server :</p>
  
  <pre><code>....
  
  app.use('/', express.static(path.join(__dirname, '../client/')), function(res, eq) {
  });
  
  app.get('/api/state', function (req, res) {
     ...
     res.end(state); // return a JSON
  });
  </code></pre>
  
  <p>When I want to load data with axios, I can't access to the url '/api/state' from my client. Indeed my routes are handled by my client and the route 'api/state' doesn't exist.</p>
  
  <p>I tried this solution :</p>
  
  <pre><code>app.get('/', function (req, res) {
    res.redirect('/index');
  });
  
  app.use('/index', express.static(path.join(__dirname, '../client/')), function(res, eq) {
  });
  
  app.get('/api/state', function (req, res) {
     ...
     res.end(state); // return a JSON
  });
  </code></pre>
  
  <p>It works but my application reacts weirdly sometimes. 
  Are there others solutions to do it ?</p>
  
  <p>Thank's for your answers.</p>