Skip to content
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

CORS partially fails when making requests with axios in React #328

Open
AdolfoRoquero opened this issue May 30, 2023 · 3 comments
Open

CORS partially fails when making requests with axios in React #328

AdolfoRoquero opened this issue May 30, 2023 · 3 comments

Comments

@AdolfoRoquero
Copy link

I am using React for the front-end running on 'http://localhost:3000' and Flask for the backend running on http://127.0.0.1:5000.
I am running into the following error
Access to XMLHttpRequest at 'http://127.0.0.1:5000/manager/personnel' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
I am using the following code to set up CORS:

cors = CORS(origins=['http://localhost:3000', 'http://127.0.0.1:3000','http://localhost:5000'])
...

def create_app(config_class=Config):
    app = Flask(__name__)
    ...
    cors.init_app(app)

I also tried using CORS at the blueprint level unsuccessfully.
What is most surprising is that some requests to the backend still succeed.

Someone had a similar issue on StackOverflow but never got a response: https://stackoverflow.com/questions/73665955/why-do-i-get-a-cors-error-with-react-axios-and-flask

@Aadesh-Baral
Copy link

Does this URL http://127.0.0.1:5000/manager/personnel exist on your backend app? Can you verify it's http://127.0.0.1:5000/manager/personnel without / at the end ?

@JacobDel
Copy link

same problem, with or without "/" at the end

@terrynguyen255
Copy link

terrynguyen255 commented Jul 20, 2023

Seems related to this unresolved issue.
I will update this comment if I can figure it out.

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

4 participants