Cross Origin Problem with Flask Api (Access-Control-Allow-Origin) - TagMerge
2Cross Origin Problem with Flask Api (Access-Control-Allow-Origin)Cross Origin Problem with Flask Api (Access-Control-Allow-Origin)

Cross Origin Problem with Flask Api (Access-Control-Allow-Origin)

Asked 1 years ago
0
2 answers

I managed to solve this.

For some strange reason "patch" with small letters was working on local but when deployed it did not work.

Changing method from "patch" to "PATCH" solved this problem.

Source: link

0

Update requirements.txt file to include Flask-CORS and install the requirements
Flask
Flask-CORS
Enable CORS globally, with permissive configurations
CORS(app)
curl command to test the configuration
$ curl -v -X OPTIONS 
    http://localhost:5000/hello
Configure Access-Control-Allow-Origin option
api_v1_cors_config = {
  "origins": ["http://localhost:5000"]
}
CORS(app, resources={"/api/v1/*": api_v1_cors_config})
curl command to test the configuration
$ curl -v -X OPTIONS 
    -H "Origin: http://localhost:5000" 
    http://localhost:5000/api/v1/hello

Source: link

Recent Questions on api

    Programming Languages