gothinkster / flask-realworld-example-app

Exemplary real world JSON API built with Flask (Python)
https://realworld.io/
MIT License
897 stars 308 forks source link

Cross-Origin Request Blocked #28

Open cnstlungu opened 5 years ago

cnstlungu commented 5 years ago

Hi everyone. I understand I'm doing something wrong, but I'm having trouble with setting up a Flask backend + Vue.js frontend.

I've added the Vue origins (port 8080) to CORS_ORIGIN_WHITELIST in settings.py, and was able to sign up and sign in. The problem occurs when I'm trying to add a new article.

I'm getting hit by the following error in the browser

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:5000/api/articles. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

I've seen a couple of suggestions online (such a browser addon to bypass this), but would really appreciate if anyone knows the proper way to do this.

Regards

    CORS_ORIGIN_WHITELIST = [
        'http://0.0.0.0:4100',
        'http://localhost:4100',
        'http://0.0.0.0:8000',
        'http://localhost:8000',
        'http://0.0.0.0:4200',
        'http://localhost:4200',
        'http://0.0.0.0:4000',
        'http://localhost:4000',
    'http://localhost:8080',
    'http://0.0.0.0:8080'
    ]