flask-vue-spa icon indicating copy to clipboard operation
flask-vue-spa copied to clipboard

if found a bug for flask 1.0.2

Open genghaolove opened this issue 3 years ago • 1 comments
trafficstars

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

genghaolove avatar Mar 10 '22 09:03 genghaolove

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!

oleg-agapov avatar Mar 13 '22 21:03 oleg-agapov