title: Express React Router Internal Server Error When Linked Directly
body: <p>I am using an express server to serve a create-react-app build. </p>
  
  <p>server.js </p>
  
  <pre><code>// Express only serves static assets in production
  if (process.env.NODE_ENV === 'production') {
    server.use(express.static('client/build')); // &lt;--- this might be causing my problem, how to make work?
  }
  
  var api = require('./routes/api');
  var email = require('./routes/email');
  
  // Define API routes before the *
  server.use('/api', api);
  server.use('/email', email);
  
  
  server.get('*', (req, res) =&gt; {
      res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
  });
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>class App extends Component {
  
  
  render() {
      return (
        &lt;Router history={browserHistory}&gt;
          &lt;Route component={Container}&gt;
            &lt;Route path="/" component={Main} /&gt;
            &lt;Route path="/catalog" component={Catalog} /&gt;
            &lt;Route path="/product/:productId" component={ProductPage} /&gt;
            &lt;Route path="/faq" component={Faq} /&gt;
            &lt;Route path="/blog" component={Blog} /&gt;
            &lt;Route path="/inquiry" component={Inquiry} /&gt;
            &lt;Route path="/cart" component={Cart} /&gt;
          &lt;/Route&gt;
        &lt;/Router&gt;
      );
    }
  }
  
  export default App;
  </code></pre>
  
  <p>Edit: 
  Updated my server.js file to show relevant code. I think the issue lies in using express.static('client/build'), but I'm not quite sure what to change it to in order to fix my routing issues.
  /Edit</p>
  
  <p>This works perfectly fine in Dev and Heroku where clicking links in the app go from route to route. For example being at the root, I can click on a link to "<a href="https://thesite.com/catalog" rel="nofollow noreferrer">https://thesite.com/catalog</a>" and the app navigates there as with any other route. </p>
  
  <p>However, if I were to copy the URL above and paste it into a new tab/browser, I get a 500 Internal Server Error. This would mean the user cannot bookmark any page other than the root. Or if another site linked to a specific route on my page it would show a 500 error. Refreshing in a page that isn't "/" returns a 500 error. Does anyone know how to fix this?</p>