title: How to use proxy in production mode with npm like proxy parameter in package.json?
body: <p>I think i need to explain a little bit more about my issue.
  I have setup a <a href="https://reactjs.org/" rel="nofollow noreferrer">react app</a> and a <a href="https://typeorm.io/#/" rel="nofollow noreferrer">typeorm</a> backend.
  In my react app i set the proxy parameter to 'localhost:3001' which is my backend. (my react app runs on 'localhost:3001').
  This works like a charm IN DEVELOPEMENT.
  However when it comes to production (for example when i build my react app and serve it with <code>npm serve -l 3000</code>) i am forced to do the proxying myself.
  I googled for this and i think the first few answers to this topic showed me that express is the way to go. So i googled more and found a package called <a href="https://www.npmjs.com/package/http-proxy-middleware" rel="nofollow noreferrer">'http-proxy-middleware'</a>.</p>
  <p>This is my code:</p>
  <pre class="lang-js prettyprint-override"><code>const { createProxyMiddleware } = require('http-proxy-middleware')
  var app = require('express')();
  const port = 80;
  
  var apiProxy = createProxyMiddleware('/api', { target: 'http://localhost:3001' });
  var normalProxy = createProxyMiddleware('/', { target: 'http://localhost:3000' });
  
  app.use(apiProxy);
  app.use(normalProxy);
  
  app.listen(port, () =&gt; {
      console.log(`Example app listening at http://localhost:${port}`)
  })
  </code></pre>
  <p>It works but not like i want it to.<br/>
  When i make a call to 'http://localhost/api' it proxys to my backend.<br/>
  When i make a call to 'http://localhost/' it proxys to my react app.<br/>
  Now when i try to call 'http://localhost/db/home' for example it gives me an 404 Error (it should proxy to 'http://localhost:3000').
  I think it also has to do with the <a href="https://reactrouter.com/web/guides/quick-start" rel="nofollow noreferrer">react dom router</a> package that i use.
  Because of that here is the content of my 'App.tsx':</p>
  <pre class="lang-js prettyprint-override"><code>import React from 'react';
  import { BrowserRouter as Router, Switch, Route } from &quot;react-router-dom&quot;;
  import 'bootstrap/dist/css/bootstrap.css';
  import './App.scss';
  import MainTab, { IMainTabProps } from './staticTabs/MainTab/MainTab';
  import { MainTab as DBMainTab } from './dashboardTabs/MainTabs/MainTab/MainTab';
  import Tab404 from './staticTabs/Tab404/Tab404';
  import StaticTabsLayout from './staticTabs/StaticTabsLayout';
  import DashboardTabsLayout from './dashboardTabs/DashboardTabsLayout';
  import Profile from './dashboardTabs/MainTabs/Profile/Profile';
  import Settings from './dashboardTabs/MainTabs/Settings/Settings';
  
  function App() {
    return (
      &lt;Router&gt;
        &lt;Switch&gt;
            &lt;Route path=&quot;/db/home&quot;&gt;
              &lt;DashboardTabsLayout&gt;
                &lt;DBMainTab /&gt;
              &lt;/DashboardTabsLayout&gt;
            &lt;/Route&gt;
            &lt;Route path=&quot;/db/me&quot;&gt;
              &lt;DashboardTabsLayout&gt;
                &lt;Profile /&gt;
              &lt;/DashboardTabsLayout&gt;
            &lt;/Route&gt;
            &lt;Route path=&quot;/db/settings&quot;&gt;
              &lt;DashboardTabsLayout&gt;
                &lt;Settings /&gt;
              &lt;/DashboardTabsLayout&gt;
            &lt;/Route&gt;
            &lt;Route path=&quot;/db/&quot;&gt;
              &lt;DashboardTabsLayout&gt;
                &lt;DBMainTab /&gt;
              &lt;/DashboardTabsLayout&gt;
            &lt;/Route&gt;
            &lt;Route path=&quot;/index.html&quot;&gt;
              &lt;StaticTabsLayout&gt;
                &lt;MainTab /&gt;
              &lt;/StaticTabsLayout&gt;
            &lt;/Route&gt;
            &lt;Route path=&quot;/verify/:UserID/:VerifyID&quot; component={(props: JSX.IntrinsicAttributes &amp; JSX.IntrinsicClassAttributes&lt;MainTab&gt; &amp; Readonly&lt;IMainTabProps&gt; &amp; Readonly&lt;{ children?: React.ReactNode; }&gt;) =&gt; &lt;StaticTabsLayout&gt;&lt;MainTab verify={true} {...props} /&gt;&lt;/StaticTabsLayout&gt;} /&gt;
            &lt;Route exact path=&quot;/&quot;&gt;
              &lt;StaticTabsLayout&gt;
                &lt;MainTab /&gt;
              &lt;/StaticTabsLayout&gt;
            &lt;/Route&gt;
            &lt;Route component={Tab404} /&gt;
        &lt;/Switch&gt;
      &lt;/Router&gt;
    );
  }
  
  export default App;
  </code></pre>
  <p><strong>Update</strong><br/>
  I also tried calling 'http://localhost:3000/db' in my Browser and this gives me also an 404. So i think it could also possibly be that my 'react-router-dom' code doesn't work.</p>