Fix Flask CORS Error: Access-Control-Allow-Origin

preview_player
Показать описание

CORS stands for Cross-Origin Resource Sharing. By default, Flask doesn't let other domains (origins) access its routes. But you can fix this using the Flask-CORS Python module to change your app's CORS policy.

0:00 - Intro
1:28 - Install Flask-CORS
1:50 - Method #1
2:54 - Method #2
6:14 - Method #3
7:58 - Wrapping up

---------------------------------------------------------------
RECOMMENDED WEB HOSTING

---------------------------------------------------------------
MY DESK SETUP GEAR

Рекомендации по теме
Комментарии
Автор

If you're trying to access Flask from another app or domain, you're probably running into this cross origin resource sharing error. Here are 3 ways to fix it using Flask-CORS!

LukePeters
Автор

Luke, thank you for such a nice, simple example. I can't tell you how many needlessly complicated "tutorials" on Flask and CORS I've recently endured before finding your beautifully simple example. Exactly what I needed to make forward progress.

brycebate
Автор

You are my final savior when every other tutorial failed! Thanks a lot.

rajaramanv
Автор

Hi. These solutions work only on successful requests for me. When I raise an exception from flask while the debug mode is active, I still receive CORS error on my angular app.

MRL
Автор

thankz its been very helpful for me <3

streetboss
Автор

Hi I’ve been getting


Any idea how this can be fixed. Great video, thanks

pranavkakade
Автор

Thank you! Has anyone ever received two requests when using a React front-end, and a Flask backend? I look into it, and apparently with CORS it has everything send a "preflight" request? I don't really understand the concept, but the thing is the messes up the body of one of the two POST requests it ends up sending.

samiam.
Автор

I was stuck on this problem for hours trying to access raspberry flask api from vue.js. You literally saved me a week of research! Thanks mate!!!!

TheCTV
Автор

Hi, when my axios 'get' request has a query param, the CORS erro arise... (without it, it works). Do you know if any additional setting is required? Could you help me, please?

anyNameHere
Автор

In my app, the Access control is whitelisted(*) for all. Which enables to request to server from any domains and required response can be retrieved. I need to restrict to my domain. How to do that?

vijayanandb
Автор

i use all of three solution but same cors problem, i am try to post angular register data to my sql db through flask api

avinashchauhan
Автор

you've done great justice to this. due to this you earn my subscription and like with a comment. thank you for saving me from the stress of unknown

nacosnounacademicdirector
Автор

Just what I needed! Straight to the point and clear explanation. Thank you!

adrianpuscuta
Автор

Great video! 'To the point' explanation! Thank you very much!

GM-qvql
Автор

Hello, I am still getting the error after following method #1. I am using Vue to make a request to the Flask backend. Any idea what may be causing the error?

uisaerospace
Автор

But I am facing issue whem sending file in body from react

KMordhwaj
Автор

Hey Luke! Thanks for the great video on cors. I have one question, can we add multiple origins in cors to access the api?

bhageerathnayini
Автор

Thank you so much ! Just what I needed !

koconeuts