title: How to serve React app and Api on same node server?
body: <p>I am trying to serve my built react app + api on same server.</p>
  <p>I've tried code this :</p>
  <pre><code>const express = require('express');
  const bodyParser = require('body-parser')
  const path = require('path');
  const app = express();
  app.use(express.static(path.join(__dirname, 'build')));
  
  app.get('/ping', function (req, res) {
      return res.send('pong');
  });
  
  app.get('/', function (req, res) {
      res.sendFile(path.join(__dirname, 'build', 'index.html'));
  });
  
  app.listen(process.env.PORT || 8080);
  </code></pre>
  <p>But whatever url I have in my browser it serves the index.html that is inside the 'build' folder (my react app).  localhost:8080/ping serves the index.html and non 'pong'.</p>