title: How to capture arbitrary paths at one route in FastAPI?
body: <p>I'm serving <strong>React</strong> app from <strong>FastAPI</strong> by
  mounting</p>
  <pre><code>app.mount(&quot;/static&quot;, StaticFiles(directory=&quot;static&quot;), name=&quot;static&quot;)
  
  @app.route('/session')
  async def renderReactApp(request: Request):
      return templates.TemplateResponse(&quot;index.html&quot;, {&quot;request&quot;: request})
  </code></pre>
  <p>by this React app get served and React routing also works fine at client side
  but as soon as client reloads on a route which is not defined on server but used in React app FastAPI return <code>not found</code> to fix this I did something as below.</p>
  <ul>
  <li><code>@app.route('/network')</code></li>
  <li><code>@app.route('/gat')</code></li>
  <li><code>@app.route('/session')</code></li>
  </ul>
  <hr />
  <pre><code>async def renderReactApp(request: Request):
      return templates.TemplateResponse(&quot;index.html&quot;, {&quot;request&quot;: request})
  </code></pre>
  <p>but it seems weird and wrong to me as I need to add every route at the back-end as well as at frontend.</p>
  <p>I'm sure there must be something like Flask <code>@flask_app.add_url_rule('/&lt;path:path&gt;', 'index', index)</code> in FastAPI which will server all arbitrary path</p>