title: ExtJS, Flask and AJAX: cross-domain request
body: <p>I'm developing a <strong>RESTful</strong> application with <strong>ExtJS</strong> (client) and <strong>Flask</strong> (server): client and server are linked by a protocol.</p>
  
  <p>The problem comes when I try to do an <strong>AJAX</strong> request to the server, like this:</p>
  
  <pre><code>Ext.Ajax.request ({
      url: 'http://localhost:5000/user/update/' + userId ,
      method: 'POST' ,
      xmlData: xmlUser ,
      disableCaching: false ,
      headers: {
          'Content-Type': 'application/xml'
      } ,
      success: function (res) {
          // something here
      } ,
      failure: function (res) {
          // something here
      }
  });
  </code></pre>
  
  <p>With the above request, the client is trying to update the user information.
  <strong>Unfortunately, this is a cross-domain request (<a href="https://stackoverflow.com/questions/1077218/are-different-ports-on-the-same-server-considered-cross-domain-ajax-wise">details</a>).</strong></p>
  
  <p>The server handles that request as follows:</p>
  
  <pre><code>@app.route ("/user/update/&lt;user_id&gt;", methods=['GET', 'POST'])
  def user_update (user_id):
    return user_id
  </code></pre>
  
  <p>What I see on the browser console is an <code>OPTIONS</code> request instead of <code>POST</code>.
  Then, I tried to start the Flask application on the 80 port but it's not possible, obviously:</p>
  
  <pre><code>app.run (host="127.0.0.1", port=80)
  </code></pre>
  
  <p>In conclusion, I don't understand how the client can interact with the server if it cannot do any AJAX request.</p>
  
  <p>How can I get around this problem?</p>