flask-vue-spa
flask-vue-spa copied to clipboard
if found a bug for flask 1.0.2
in frontend/src/components/Home.vue http://localhost:5000/api/random and run.py @app.route('/api/random') the route looks like can not run report a bug :
Access to XMLHttpRequest at 'http://localhost:5000/api/random' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
i modify it http://localhost:5000/api/random/ and @app.route('/api/random/') this be ok
Indeed, it is a bit confusing in Flask that you have to follow this slash strictly.
I recommend just adding a trailing slash to the route definition and use it in your AJAX request.
(Another solution is probably disable CORS for whitelisted domains in Flask, but this can be tricky/impossible sometimes.)
Thanks!