title: how to use serve static file with express and react?
body: <p>I have a project made with create-react-app and i would like to use it within express ( as i need some back end functionnality).</p>
  
  <p>basically, my server render a blank page when i run it....
  here is the code of my server:</p>
  
  <pre><code>    const express = require('express');
  const path = require('path');
  
  const app = express();
  
  // Serve the static files from the React app
  app.use(express.static(path.join(__dirname, 'public')));
  
  // An api endpoint that returns a short list of items
  app.get('/api/getList', (req,res) =&gt; {
      var list = ["item1", "item2", "item3"];
      res.json(list);
      console.log('Sent list of items');
  });
  
  // Handles any requests that don't match the ones above
  app.get('*', (req,res) =&gt;{
      res.sendFile(path.join(__dirname , 'public', 'index.html'));
  });
  
  
  const port = process.env.PORT || 5000;
  app.listen(port);
  
  console.log('App is listening on port ' + port);
  </code></pre>
  
  <p>if i enter the endpoint <a href="http://localhost:5000/api/getList" rel="nofollow noreferrer">http://localhost:5000/api/getList</a>, i can see the result, but when i want to display my react app for the other end point, the page is blank.</p>
  
  <p>The react app use different Route and i also added a proxy in the package.json.</p>
  
  <p>my server source file is at the root of the react app like the image.
  <a href="https://i.stack.imgur.com/F1biD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F1biD.png" alt="enter image description here"></a></p>
  
  <p>Does someone has an idea why the react app doesnt show?</p>
  
  <p>Thanks</p>