4

I've a flask endpoint where I've permitted CORS in the following manner.

app = Flask(__name__)
CORS(app, resources={r"/api/*": {"origins": "*"}})
app.register_blueprint(store, url_prefix='/api/')

I still run into the following issue.

Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. Origin 'http://something.com:8888' is therefore not allowed access.

Any suggestions as to how I can fix this.

sideshowbarker
  • 62,215
  • 21
  • 143
  • 153
Melissa Stewart
  • 2,671
  • 8
  • 29
  • 72

1 Answers1

2

try this:

#Add these imports
from flask import jsonify
from flask_cors import CORS

#Add an app level config in this format
app = Flask(__name__)
CORS(autoINFER_app, resources={r"/*": {"origins": "*"}}, send_wildcard=True)

#While returning the GETs add this line
response = jsonify(all_dict)
response.headers.add('Access-Control-Allow-Origin', '*')
return response

This should take care of all permutations which might cause this.

Anand Tripathi
  • 8,458
  • 1
  • 30
  • 38
kaulmonish
  • 357
  • 2
  • 17