AlJohri / pickupapp-flask

0 stars 0 forks source link

Integrate Angular using CORS compatible code #1

Open AlJohri opened 10 years ago

AlJohri commented 10 years ago

@salamander29

Can you commit our last changes that made the repository CORS compatible?

CC: @Diffeomorphism

Diffeomorphism commented 10 years ago

@salamander29 OK so I pulled the most recent code, and it seems to be a step in the right direction. However, there still seems to be an issue because the response is not returning an Access-Control-Allow-Origin header. I tried my best to get Python to return the header but it couldn't be done.

If you want to test it out yourself, to any page's controller (e.g. GamesCtrl in main.js), add the following code:

$http({method: 'GET', url: 'http://localhost:5000/api/games/'}).success(function(data) {
        console.log(data);
    });

This will fire off a GET request to Flask. Then open up the Javascript console and go to the page for the controller. At current, what you should see is that in the console there's a message like "XMLHttpRequest cannot load http://localhost:5000/api/games/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:9000' is therefore not allowed access.". If you go to Network and click on the call to api/games, you'll see that it gets cancelled, and there's no Access-Control-Allow-Origin header in the response.

tl;dr: Figure out how to get Flask to return the Access-Control-Allow-Origin header.

AlJohri commented 10 years ago

@salamander29 @Diffeomorphism

Guys the code for flask CORS isn't even in the flask repository yet...

https://github.com/AlJohri/pickupapp/issues/6#issuecomment-36122735