You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An application proxy that can be used to transparently transfer all kind of requests ( including of course XMLHTTPRequest ) to any third part domain. It is possible to define a list of acceptable third party domains and you are encouraged to do so. Otherwise the proxy is open to any kind of requests.
3
+
*Formerly known as "PHP Cross Domain (AJAX) Proxy"*
5
4
6
-
If it is possible to enable CORS on your application server, this proxy is not necessary. Have a look at [how you can enable CORS on your server](http://enable-cors.org/server.html) for further information.
5
+
A CORS proxy that allows cross domain requests. It can be used to access resources from third part websites when it's not possible to enable CORS.
7
6
8
-
PHP 5.3+
7
+
**Note**: Please check whether this solution is indeed necessary by having a look at [how you can enable CORS on your server](http://enable-cors.org/server.html).
9
8
10
-
Installation
11
-
--------------
9
+
## Overview
12
10
13
-
The proxy is indentionally limited to a single file. All you have to do is to place `proxy.php` under your application
14
11
15
-
Whenever you want to make a cross domain request, just make a request to http://www.yourdomain.com/proxy.php and specify the cross domain URL by using `csurl` parameter. Obviously, you can add more parameters according to your needs; note that the rest of the parameters will be used in the cross domain request. For instance, if you are using jQuery:
12
+
### Features
13
+
14
+
* Acts as a reverse proxy: request headers and data are propagated from proxy to server. Similarly, response headers and data are propagated from proxy to client.
15
+
* Provides support for all methods GET, POST, PUT, DELETE.
16
+
* Requests can be filtered against a list of trusted domains / URLs.
17
+
* External configuration (Work in progress)
18
+
* Error handling i.e. when server is not available (Work in progress)
See also the list of [contributors](https://github.com/softius/php-cross-domain-proxy/graphs/contributors) which participated in this project.
29
+
30
+
31
+
### License
32
+
33
+
PHP CORS Proxy is licensed under GPL-3.0. See `LICENCE.txt` file for further details.
34
+
35
+
36
+
## Installation
37
+
38
+
**Using composer**
39
+
40
+
```
41
+
composer require softius/cors-proxy
42
+
```
43
+
44
+
**Manual installation**
45
+
46
+
The proxy is indentionally limited to a single file. All you have to do is to place `proxy.php` under the public folder of your application.
47
+
48
+
### Configuration
49
+
50
+
For security reasons don't forget to define all the trusted domains / URLs into top section of `proxy.php` file:
It’s worth mentioning that all request methods are working GET, PUT, POST, DELETE are working and headers are taken into consideration. That is to say, headers sent from browser to proxy are used in the cross domain request and vice versa.
59
+
**Note**: There is currently ongoing work to allow configuration outside the `proxy.php`
60
+
61
+
## Usage
62
+
It is possible to initiate a cross domain request either by providing the `X-Proxy-URL` header or by passing a special `GET` parameter. The former method is strongly suggested since it doesn't modify the request query. Also, the request looks more clear and easier to understand.
63
+
64
+
### Using headers
28
65
29
-
You can also specify the URL with the `X-Proxy-URL` header, which might be easier to set with your JavaScript library. For example, if you wanted to automatically use the proxy for external URL targets, for GET and POST requests:
66
+
It is possible to specify the target URL with the `X-Proxy-URL` header, which might be easier to set with your JavaScript library. For example, if you wanted to automatically use the proxy for external URL targets, for GET and POST requests:
For security reasons don't forget to define all the valid requests into top section of `proxy.php` file:
83
+
84
+
### Using query
85
+
86
+
In order to make a cross domain request, just make a request to http://www.yourdomain.com/proxy.php and specify the target URL by using the `csurl` (GET) parameter. Obviously, you can add more parameters according to your needs; note that the rest of the parameters will be used in the cross domain request. For instance, if you are using jQuery:
0 commit comments