title: react router with flask back end
body: <p>I am building a project with react as frontend and flask as backend. I want the application created by 'create-react-app' to use front end routing with 'react-router-dom' package. Relevant code in index.js:</p>
  
  <pre><code>&lt;BrowserRouter&gt;
    &lt;Switch&gt;
      &lt;Route exact path="/" component={Home} /&gt;
      &lt;Route path="/about" component={About} /&gt;
      &lt;Route component={Notfound} /&gt;
    &lt;/Switch&gt;
  &lt;/BrowserRouter&gt;
  </code></pre>
  
  <p>Then I want to serve it via flask, so in flask I have following settings and routing rules:</p>
  
  <pre><code>app = Flask(__name__, static_folder="../build/static", template_folder="../build")
  
  @app.route('/', defaults={'path': ''})
  def serve(path):
      render_template("index.html")
  </code></pre>
  
  <p>Where index.html is built with <code>npm run build</code>. When I click on navbar and redirect to <code>/about</code>, app returns 404 not found.</p>
  
  <p>Also there's another error in the browser console, which shows: <code>Manifest: Line: 1, column: 1, Unexpected token.</code></p>
  
  <p>Any help is appreciated.</p>