0

I have flask api(http://127.0.0.1:5000/out/) which return the json. Angular js is http://localhost:4300 also running

I have added the extension Moesif Orign & CORS Changer and switched on also 'Access-Control-Allow-Origin':'*'

Error is below

Access to XMLHttpRequest at 'http://127.0.0.1:5000/out/' from origin 'http://localhost:4300' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Already gone the link Why does my JavaScript code get a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error when Postman does not?

1 Answers1

0

fix with below code

from flask_cors import CORS, cross_origin
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})

@cross_origin(origin='*')