Skip to content

if found a bug for flask 1.0.2 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
genghaolove opened this issue Mar 10, 2022 · 1 comment
Open

if found a bug for flask 1.0.2 #12

genghaolove opened this issue Mar 10, 2022 · 1 comment

Comments

@genghaolove
Copy link

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

@oleg-agapov
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants