flask redirect "XMLHttpRequest cannot load..." error localhost
<p>Running flask locally, trying to call:</p>

<pre><code>@app.route('/foo_route', methods=['POST'])
@cross_origin(origin='*')
def foo():
    return redirect("https://www.google.com/")
</code></pre>

<p>And I get the following error:</p>

<blockquote>
  <p>XMLHttpRequest cannot load <a href="https://www.google.com/" rel="nofollow">https://www.google.com/</a>. No
  'Access-Control-Allow-Origin' header is present on the requested
  resource. Origin '<a href="http://127.0.0.1:5000" rel="nofollow">http://127.0.0.1:5000</a>' is therefore not allowed
  access</p>
</blockquote>

<p>I tried to use CORS as such:</p>

<pre><code>app = Flask(__name__)
CORS(app)
</code></pre>

<p>along with the @cross_origin() on my route. What is going wrong here? I was reading this may be a chrome bug when running locally?
.</p>

<p>What I decided to do was to pass the url to the client and then have the client redirect.</p>

<pre><code>@app.route('/foo_route', methods=['POST'])
@cross_origin(origin='*')
def foo():
    return "https://www.google.com/"
</code></pre>

<p>Then on the client (javascript):</p>

<pre><code>window.location.href = serverSentUrl;
</code></pre>

python flask flask-cors