BrowserHistory in Node/Express with API
<p>I am attempting to implement BrowserHistory for a React app that uses react-router. Based on <a href="https://github.com/reactjs/react-router/blob/1.0.x/docs/guides/basics/Histories.md" rel="nofollow">the documentation</a>, I have in my <code>index.js</code>:</p>

<pre><code>let express = require('express');
let harp = require('harp');
let path = require('path');

let app = express();

app.use(express.static(__dirname + "/dist"));
app.use(harp.mount(__dirname + "/dist"));

// BrowserHistory code
app.get('*', function (request, response){
  response.sendFile(path.resolve(__dirname, 'dist', 'index.html'));
});

let port = process.env.PORT || 3333;
app.listen(port, () =&gt; console.log("Listening on port " + port) );

// ...
// Various app.get(...) endpoints below
// ...
</code></pre>

<p>However, this is now catching all API requests (for example, I want to make a GET request to <code>/metric</code>) and returning <code>index.html</code> instead of the correct JSON data.</p>

<p>How do I implement BrowserHistory and have API endpoints?</p>