I have Flask Python API with cors set up as below. It works fine when invoked from browser. But getting CORS error when called from Angular application currently testing from localhost:4200.
From Chrome developer tools - Could see preflight request with Request Method=Options(Preflight request) returning 200, but actual request is throwing CORS error. Not sure what i am doing wrong here. Please share insights.
FYI - Tried couple of tweaks like making allowed origin "*" , removed "supports_credentials=True"; still same CORS error
Error:
Error:
Access to XMLHttpRequest at 'https://app01.dev.com/coreengine?rootfolder=app01&childfolder=jun2020&team=app01&action=customhierarchy' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Code:
from flask_cors import CORS
mainapp = Flask(__name__)
cors = CORS(mainapp, resources={r"/*": {"origins":["http://localhost:4200"]}},supports_credentials=True)
@mainapp.route('/coreengine', methods=['GET','POST'])
def coreengine():
{
#Code
}