corydolphin / flask-cors

Cross Origin Resource Sharing ( CORS ) support for Flask
https://flask-cors.readthedocs.io/en/latest/index.html
MIT License
889 stars 140 forks source link

Issue with setting up origins #211

Closed shgam2 closed 6 years ago

shgam2 commented 6 years ago

Hello there,

I've been struggling to set up the CORS correctly for a couple of days now. My intent is to only allow certain URLs to access the server that I've built, but it's not working as I expected. So I created a new python server on the local with the code provided in the link: (https://github.com/corydolphin/flask-cors/blob/master/examples/app_based_example.py) and changed the line 32 to this: CORS(app, resources={r"/api/*": {"origins": "https://www.example.com"}}) Just to see if I actually get "blocked" when I try to access my local server (those pages that meet the resource requirements) on my browser.

Am I doing something wrong? I'm not sure if this is a place where I can ask questions but I really wish I can get some answer here.. Running (flask_cors 3.0.3)

Thanks, Brian

corydolphin commented 6 years ago

Hey Brian,

CORS is a system which browsers use to enforce secure communication when a page loaded on domain A wants to communicate with something on domain B. It won’t change how a browser simply loads content from B, but rather content loaded from B while on A.

Does that make sense?