title: Create-React-App in production: Routes not found
body: <p>I have a fullstack app with Create-React-App and Express.js as the backend.</p>
  
  <p>The development setup (CRA running on port 3000) is realized by CRA's proxies so I can forward certain routes directly to the backend (running on port 5000):</p>
  
  <pre><code>"proxy": {
      "/auth/*": {
        "target": "http://localhost:5000"
      },
      "/api/*": {
        "target": "http://localhost:5000"
      }
  }
  </code></pre>
  
  <p>For logging out a user I have a corresponding route:</p>
  
  <pre><code>app.get('/api/logout', (req, res) =&gt; {
      req.logout();
      res.redirect('/');
  });
  </code></pre>
  
  <p>And a logout button that points to this route:</p>
  
  <pre><code>&lt;a key="logout" href="/api/logout"&gt;Logout&lt;/a&gt;
  </code></pre>
  
  <p><strong><em>In development mode</em></strong>, running :3000 and :5000, everything works perfectly. Clicking on on the button sets the URL in the browser which calls the route, the proxy forwards and the backend recognizes and handles the request properly    =>   Session killed!</p>
  
  <p><strong><em>In production mode</em></strong>, hosted on Heroku, the route is simply not found and not triggered. In the network tab the server serves the static html file, maybe due to this configuration:</p>
  
  <pre><code>if (process.env.NODE_ENV === 'production') {
  
      app.use(express.static('client/build'));
  
      const path = require('path');
      app.get('*', (req, res) =&gt; {
          res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
      });
  }
  </code></pre>
  
  <p>If I logout the user <strong><em>programmatically</em></strong>, by calling the same route <code>onClick</code>, it works:</p>
  
  <pre><code>await axios.get('/api/logout');
  </code></pre>
  
  <p>But why is the simple redirect of the browser with the <code>&lt;a&gt;</code> not working in production?</p>
  
  <p>THX!</p>