title: Flask restful api enabling CORS is not working for remote ajax call
body: <p>I have a flask app in which I have an restful api which I am trying to call through a remote server.</p>
  
  <p><strong>init</strong> File :-</p>
  
  <pre><code>from flask.ext import restful
  from flask.ext.cors import CORS
  
  app = create_app(__name__)
  app.config['CORS_HEADERS'] = 'Content-Type'
  cors = CORS(app, resorces={r'/d/&lt;string:d_name&gt;': {"origins": '*'}})
  api=restful.Api(app)
  api.add_resource(g_Api, '/g/&lt;string:g_id&gt;')
  api.add_resource(d_Api, '/d/&lt;string:d_name&gt;')
  </code></pre>
  
  <p>Now the d_Api class :-</p>
  
  <pre><code>from flask import Flask, render_template, g
  from flask.ext.restful import reqparse, abort, Api, Resource
      def abort_if_not_exist(d_name):
        return d_name
  
      class d_Api(Resource):
        def __init__(self):
          self.d=d
  
        def get(self, d_name):
          val=abort_if_not_exist(d_name)
          return val
  </code></pre>
  
  <p>This works fine from the same localhost server returns the correct result. The server running on localhost has an ajax call to the api,</p>
  
  <pre><code>$.ajax({
                                      async: false,
                                      type: 'GET',
                                      url: 'http://localhost:8080/d/'+d_name,
                    success: function(data) {
                                          alert(data);
                                          }
  });
  </code></pre>
  
  <p>When called from remotehost doesn`t return any response, instead in Firefox I get Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource d . This can be fixed by moving the resource to the same domain or enabling CORS.</p>
  
  <p>I<code>m not sure how else to configure CORS for this api endpoint. I</code>m using python 2.6 and 'flask-cors'.</p>
  
  <p>I  found this difference : when i try to hit the api from the localhost - <code>2015-03-09 11:40:35 - Flask-Cors:385 - INFO - CORS request from Origin:xyz-ld2.abc.biz:8080, setting Access-Control-Allow-Origin:*</code> 
  When i try to hit the api from a remote host : <code>2015-03-09 11:47:15 - Flask-Cors:385 - INFO - CORS request from Origin:None, setting Access-Control-Allow-Origin:*</code> </p>