Created
December 1, 2015 20:21
-
-
Save marcusasplund/0a67562ec775c461a53b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a really, really simple proxy to request | |
// non-CORS enabled webservices | |
// Drop this script on your server and prepend | |
// the url you want to access like e.g. | |
// $.getJSON("http://pathtouyourserver.com/folderwiththisscript/corsproxy.php?url=http://theapiwithoutcors.com").success(.... | |
// | |
// You find a more sophisticated one here: http://benalman.com/projects/php-simple-proxy/ | |
<?php | |
$url = $_GET['url']; | |
$content = file_get_contents($url); | |
header('Access-Control-Allow-Origin: *'); | |
echo $content; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a quick headsup for anyone using this in production, this is vulnerable to lookup attacks (e.g. corsproxy.php?url=../../../etc/passwd).