cors-bypass-proxy
A PHP proxy to solve client browser HTTP CORS(cross-origin) restrictions.
A simple way to solve CORS issue when you have no access to the endpoint server is to have a proxy on your server, and this is just that, this may not take care of all security flaws but it does solve CORS issues.
Installation
Since proxy.php
is indepedent and light, just simply upload it to your server
Usage with Jquery
$.ajax({
url: "myserver/proxy.php",
type: "POST", //endpoint request type
crossDomain: true,
//set request header here if needed by endpoint
data: {
"cors": "http://example-api.com/endpoint", //endpoint URL
"method": "POST", // should be the same with endpoint request type
//endpoint data comes
"param1": value,
"param2": value
},
success: function (data) {
console.log(data)
}
});
Now you have made a clean cross domain request
Note
You can add headers specified by the api endpoint or server you are trying to access, request type valid for proxy are POST and GET methods only, method and cors parameter are compulsory fields for the proxy to work, Request type and method parameter should be the same and should be the valid method for the API/server endpoint