├── .vscode
└── settings.json
├── LICENSE
├── README.md
├── app
├── config
│ └── config.sample.ini
├── database
│ └── cors-proxy.sql
└── templates
│ └── default
│ ├── error.phtml
│ ├── frontend.phtml
│ └── sitemap.pxml
├── bin
├── cs
├── cs.bat
├── test
└── test.bat
├── composer.json
├── src
├── Application.php
├── Config.php
├── Exception
│ ├── FileNotFoundException.php
│ └── MalformedConfigFileException.php
├── Helpers.php
└── RequestHandler.php
└── www
├── .htaccess
├── assets
└── default
│ ├── css
│ └── main.css
│ ├── img
│ └── favicon.ico
│ └── js
│ └── main.js
├── index.php
└── robots.txt
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.insertSpaces": true,
3 | "editor.tabSize": 4
4 | }
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 HTMLDriven
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CORS proxy
2 |
3 | [](https://travis-ci.org/htmldriven/cors-proxy)
4 | [](https://insight.sensiolabs.com/projects/edb8e93a-2918-41e7-8667-7bf2dfe3b492)
5 | [](https://packagist.org/packages/htmldriven/cors-proxy)
6 | [](https://packagist.org/packages/htmldriven/cors-proxy)
7 |
8 | CORS proxy is a free service for developers who need to bypass same-origin policy related to performing standard AJAX requests to 3rd party services.
9 |
10 | ## Documentation
11 |
12 | Learn more in the [documentation](docs/en/index.md).
13 |
14 | ## Project home
15 |
16 | You can find more information about the CORS proxy on project website [cors-proxy.htmldriven.com](https://cors-proxy.htmldriven.com).
17 |
--------------------------------------------------------------------------------
/app/config/config.sample.ini:
--------------------------------------------------------------------------------
1 | urlParameterName = 'url'
2 | userAgent = 'htmldriven/cors-proxy 1.0'
3 | templateFile = '../app/templates/default/frontend.phtml'
4 | sitemapPath = '/sitemap.xml'
5 | sitemapTemplateFile = '../app/templates/default/sitemap.pxml'
6 | errorTemplateFile = '../app/templates/default/error.phtml'
7 |
--------------------------------------------------------------------------------
/app/database/cors-proxy.sql:
--------------------------------------------------------------------------------
1 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
2 | SET time_zone = "+00:00";
3 |
4 | CREATE TABLE IF NOT EXISTS `request_log` (
5 | `id` int(10) unsigned NOT NULL,
6 | `method` enum('GET','POST','PUT','DELETE','OPTIONS','HEAD','TRACE','CONNECT','PATCH') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'GET' COMMENT 'HTTP request method.',
7 | `scheme` varchar(16) COLLATE utf8_unicode_ci NOT NULL COMMENT 'HTTP request scheme.',
8 | `host` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'HTTP request host domain/ip.',
9 | `path` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'HTTP request URL path relative to host. Path should always start with ''/'' character.',
10 | `query` text COLLATE utf8_unicode_ci COMMENT 'Query string part of the URL.',
11 | `user_agent` text COLLATE utf8_unicode_ci COMMENT 'Client string identifier.',
12 | `request_headers` text COLLATE utf8_unicode_ci COMMENT 'All HTTP request headers in JSON format.',
13 | `request_body` mediumtext COLLATE utf8_unicode_ci COMMENT 'Request payload data.',
14 | `response_headers` text COLLATE utf8_unicode_ci COMMENT 'All HTTP response headers in JSON format.',
15 | `response_body` mediumtext COLLATE utf8_unicode_ci COMMENT 'Response payload data.',
16 | `date_created` datetime NOT NULL COMMENT 'Date in UTC.'
17 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
18 |
19 |
20 | ALTER TABLE `request_log`
21 | ADD PRIMARY KEY (`id`),
22 | ADD KEY `path` (`path`(255)) USING BTREE;
23 |
24 |
25 | ALTER TABLE `request_log`
26 | MODIFY `id` int(10) unsigned NOT NULL AUTO_INCREMENT;
27 |
--------------------------------------------------------------------------------
/app/templates/default/error.phtml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
CORS proxy is a free service for developers who need to bypass same-origin policy related to performing standard AJAX requests to 3rd party services.
72 |
You can simply use this website as quickest way to finally start doing some cross-domain requests and even you can run this service on your own webserver. If you prefer running the service on your own, follow the instructions in Setup section.
73 |
You can customize the service parameters to fit your own needs (including this front-end page template).
74 |
75 |
76 |
77 |
How to use
78 |
The CORS proxy service expects you provide the URL of 3rd party service/page in url HTTP GET parameter by default. A final cross-domain request URL via the CORS proxy service can be handled, looks something like this:
You can test the CORS proxy service response using the form above.
83 |
84 |
85 |
86 |
Setup
87 |
Read the following section if you want to run the CORS proxy on your own webserver.
88 |
89 |
Requirements
90 |
Please, check the composer.json file or packagist.org to see the current list of requirements in terms of packages which are required by composer. Except for PHP version >=5.6 with CURL extension being installed, there are no more odd requirements
91 |
92 |
Installation
93 |
The best way to install the CORS proxy is using the composer. You can do that using the following command:
* Note that my-cors-proxy in the command above is the name of target directory for newly created CORS proxy project, so this name is totally up to you.
96 |
Then, create a destination database using the cors-proxy.sql initialization script.
97 |
98 |
Configuration
99 |
If you need, you can customize the CORS proxy by creating custom config.ini file. This file must be located at app/config directory. There's already config.sample.ini file, which you can just copy and edit some parts of it to match your needs.
100 |
There are several config items which you can change. The following list shows all supported options:
101 |
102 |
urlParameterName = url - name of URL HTTP GET parameter name
103 |
userAgent = htmldriven/cors-proxy 1.0 - HTTP User-Agent string which is used during cross-domain requests
104 |
templateFile = app/templates/default/frontend.phtml - path to main front-end page template file
105 |
sitemapPath = /sitemap.xml - URL path to sitemap file
106 |
sitemapFile = app/templates/default/sitemap.pxml - path to sitemap XML template file
107 |
timezone = UTC - default PHP timezone settings used for DateTime instances
108 |
database = ... - database connection settings
109 |
110 |
111 |
112 |
113 |
License
114 |
CORS proxy is totally free as it's available and being distributed under The MIT License.
115 |
116 |
117 |
118 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
Response
130 |
131 |
132 | Copy the following request URL to use it in your app:
133 |
134 |
135 |
136 |