Skip to content Skip to sidebar Skip to footer

No 'access-control-allow-origin' Header But No Access To Api

I'm trying to use the UK Parliament API but I'm hitting this error: XMLHttpRequest cannot load http://findyourmp.parliament.uk/api/search?q=london&f=js. No 'Access-Control-All

Solution 1:

yes using serverside "proxy" would solve the problem, as the Access-Control-Allow_Origin is for client-side calls

simple php snippet

$search_term = "find";
$url = "http://findyourmp.parliament.uk/api/search?q=".$search_term."&f=js";
return file_get_contents($url);

Post a Comment for "No 'access-control-allow-origin' Header But No Access To Api"