title: Flask and React routing
body: <p>I'm building the Flask app with React, I ended up having a problem with routing.</p>
  
  <p>The backend is responsible to be an API, hence some routes look like:</p>
  
  <pre><code>@app.route('/api/v1/do-something/', methods=["GET"])
  def do_something():
      return something()
  </code></pre>
  
  <p>and the main route which leads to the React:</p>
  
  <pre><code>@app.route('/')
  def index():
      return render_template('index.html')
  </code></pre>
  
  <p>I'm using <a href="https://github.com/rackt/react-router">react-router</a> in the React app, everything works fine, react-router takes me to <code>/something</code> and I get the rendered view, but when I refresh the page on <code>/something</code> then Flask app takes care of this call and I get <code>Not Found</code> error.</p>
  
  <p>What is the best solution? I was thinking about redirecting all calls which are not calling <code>/api/v1/...</code> to <code>/</code> it's not ideal as I will get back the home page of my app, not rendered React view.</p>