Running into CORS problems with angular js

Avatar image for stv
stv

3

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#1  Edited By stv

I am using angular js and trying to make an api call, but I keep getting CORS errors in my javascript console. My api call looks like this

$http.get("http://www.comicvine.com/api/characters/?api_key=key&limit=10&format=json") 

But whenever I run this code I am getting this error in my console.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.comicvine.com/api/characters/?api_key=[key]4&limit=10&format=json. This can be fixed by moving the resource to the same domain or enabling CORS.

Does anyone know how I can get past this? Is it because I am running my server on localhost? Thanks

Avatar image for stv
stv

3

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

I figured it out, ended up using a flask server to re-route the data.

Avatar image for adrianrodriguez
adrianrodriguez

16

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

How did you go about this? I am trying to accomplish the same thing, but I'm unaware of how to use a flask server.

Avatar image for donnrri
donnrri

5

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@adrianrodriguez:

Hi

Can you use Node.js ? If so then perhaps you could use express.js and redirect using

server.use('your-path', function(req, res) { 
var url = 'your-redirect-url;
req.pipe(request(url)).pipe(res); });

Reply if you need more information or look on stackoverflow using the '
req.pipe(request(url)).pipe(res)' string
Avatar image for adrianrodriguez
adrianrodriguez

16

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@donnrri: I actually wound up figuring it out, and already am well into my app using Angular :) Thanks though.

Avatar image for red2678
red2678

1

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0