title: Express regex routes no longer know how to load static assets
body: <h1>Question</h1>
  
  <p>How can I use regex or Express' build-in URL processor to correctly load static files?</p>
  
  <h1>Expected Behavior</h1>
  
  <p>Express should match the first route it's found and load files like normal.</p>
  
  <h1>Actual Behavior</h1>
  
  <ul>
  <li>Getting errors that static files are not of the correct MIME type.</li>
  <li>React's <code>manifest.json</code> is being not loaded correctly.</li>
  </ul>
  
  <h1>Explanation</h1>
  
  <p>I'm trying to specify to my Express router where to find static files, using React. I've tried a few with only one solution so far but it means repeating basically the same line twice. Now, I'm hoping to turn this into a single call to the <code>.use()</code> method either using regex or Express' built-in string route processor.</p>
  
  <h1>Current working solution</h1>
  
  <pre><code>app.use('/expressadminarea', express.static(__dirname + '/views')
  app.use('/expressadminarea/?*', express.static(__dirname + '/views')
  </code></pre>
  
  <h1>What <strong>should</strong> work but does not</h1>
  
  <pre><code>app.use(/expressadminarea\/.*|\/expressadminarea/, express.static(__dirname + '/views')
  </code></pre>
  
  <p>In the second solution, I'm telling Express to explicitly look for <code>/expressadminarea/&lt; anything or nothing &gt;</code> or <code>/expressadminarea</code>. I've checked the regex and it matches any route I need it to but for some reason Express no longer knows how to load the static assets, CSS, JS, etc. Reverting to the first solution and the exact same path(s) that Express was previously searching to find the static assets now load completely fine.</p>
  
  <h1>The exact error I am receiving is:</h1>
  
  <p><a href="https://i.stack.imgur.com/FPpxu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FPpxu.png" alt="Error Message"></a></p>
  
  <h1>Things to note</h1>
  
  <ul>
  <li>I am using React for the views
  
  <ul>
  <li>Build flow is weird but I am running a modified version of the <code>yarn/npm build</code> that will run a normal build and move the files to my specified <code>/views</code> directory, the one my Express server is looking for.</li>
  <li>This build dir is not modified so all internal files/directories are the same as a normal build from React.</li>
  <li>I have specified that React should start looking at the <code>&lt;&lt; domain name &gt;&gt;/expressadminarea</code> before attempting to load assets with a custom <code>.env</code> file and placing <code>PUBLIC_URL="/expressadminarea"</code> inside.</li>
  <li>I do not recall making any changes to the <code>manifest.json</code> file but it seems to be popping up as an error, although I don't think it's the cause of any problems, so as a reference:</li>
  </ul></li>
  </ul>
  
  <h1>manifest.json</h1>
  
  <pre><code>{
    "short_name": "React App",
    "name": "Create React App Sample",
    "icons": [
      {
        "src": "favicon.ico",
        "sizes": "64x64 32x32 24x24 16x16",
        "type": "image/x-icon"
      }
    ],
    "start_url": ".",
    "display": "standalone",
    "theme_color": "#000000",
    "background_color": "#ffffff"
  }
  </code></pre>