145 Commits

Author SHA1 Message Date
Rob Wu
beadd3fe77 v0.1.9 - Always use Access-Control-Allow-Origin: *
Fixes #6
2014-03-12 18:18:08 +01:00
Rob Wu
7983d1e7ae Update dev dependency
To test for mem leaks, just run node test/runner.js
and follow the instructions.
2014-01-03 14:21:49 +01:00
Rob Wu
88797acc38 Version 0.1.8 2013-10-19 14:42:22 +02:00
Rob Wu
a322df91c4 Header checks after error checks
With this commit, you will see the following messages instead of
"Missing required request header ...":

 /iscorsneeded = no with direct browsing
 /favicon.ico = 404 not found
2013-09-10 23:10:14 +02:00
Rob Wu
4b308db027 Corrected typo in README
Consequence of error:
- Requests to the CORS anywhere API are prefixed as well, i.e.
  https://cors-anywhere.herokuapp.com/ ->
  https://cors-anywhere.herokuapp.com/https://cors-anywhere.herokuapp.com/

Impact of error:
- Minimal. The functionality of the API is not affected.
2013-09-03 18:08:00 +02:00
Rob Wu
8caf221cc2 Version 0.1.7 2013-08-30 11:43:11 +02:00
Rob Wu
d2023b45e1 Fix POST -> GET conversion on redirect 2013-08-30 11:42:51 +02:00
Rob Wu
a784fc96f8 Simplified demo.html; show proxyError on error 2013-08-29 19:20:40 +02:00
Rob Wu
cd97423db9 Fix memory leak 2013-08-29 15:17:19 +02:00
Rob Wu
b76d6457f0 Add some tests (mainly interested in memleak test)
If you wish to check if the API works, launch demo.html,
set the global cors_api_url variable to your local instance,
enter an URL and press "GET" or "POST".
2013-08-29 14:25:20 +02:00
Rob Wu
a56fb8843c Add X-Final-URL 2013-08-29 10:12:03 +02:00
Rob Wu
721ba7609d Remove unused code 2013-08-28 21:04:48 +02:00
Rob Wu
3bb98d6bea Add X-CORS-Redirect-# header for debugging 2013-08-28 20:50:46 +02:00
Rob Wu
d7a6564574 Bind proxyRequest event handler once per proxy
Optimization: Create onProxyResponse handler only once,
and bind it only once per HttpProxy instance
(opposed to binding it for every request)
2013-08-28 19:48:52 +02:00
Rob Wu
96d237e7b3 [WIP] Support internal redirects
TODO:
- Move proxyRequest elsewhere, and attach the request state to req
- Investigate the implications of calling req.emit('end');
  (It's called in order to trigger reverseProxy.end(), needed to start
  the redirect)
2013-08-28 18:49:51 +02:00
Rob Wu
de0318bc4c Refactored; move URL parser to separate function 2013-08-28 17:35:23 +02:00
Rob Wu
c37e496dee Add extra documentation (in code).
Removed ? from path's regexp, because
"http://cors-anywhere/" + "/domain.com/file" =
"http://cors-anywhere//domain.com/file" SHOULD be an invalid request.

"//domain.com/file" can be resolved to "http://domain.com/file", but
"/domain.com/file" should resolved to http://host/domain.com/file,
but since the host is unknown, the API should just fail.
2013-08-28 13:17:58 +02:00
Rob Wu
198e927baa Use proxyRequest event instead of subst. writeHead
Makes the code less dependent on implementation details.
2013-08-28 11:49:39 +02:00
Rob Wu
9410ff5afa Remove manual redirect handling
From now on, redirects will automatically be handled by the browser.
Using the API by clients has become extremely easy.

Included JavaScript / jQuery snippets in the documentation to
demonstrate that it's easy to use the API.
2013-08-27 18:51:04 +02:00
Rob Wu
61d55ae41e Avoid preflight request by relaxing header req
One of the following headers is required by default:
- Origin: This header is always sent with CORS requests.
- X-Requested-With: This header is automatically added by jQuery on
  same-origin requests.

These two headers effectively disable the ability to use the CORS
proxy for regular browsing.
2013-08-27 16:15:10 +02:00
Rob Wu
6d9b268ecc Update header-modifying method - v0.1.4
node-http-proxy sets headers before using writeHead.
2013-07-23 22:29:02 +02:00
Rob Wu
b35a6f5ffb Redirect URL in statusText
Android's stock browser (and Webview) does not recognize the
Access-Control-Expose-headers response header.
Use the status text field to pass through this information.

Updated demo and documentation.
2013-07-23 21:55:32 +02:00
Rob Wu
ba185f5ec8 Version bump to 0.1.3 2013-06-10 18:38:59 +02:00
Rob Wu
aee875ac67 https -> target.https 2013-06-10 18:38:15 +02:00
Rob Wu
367b648114 Avoid double ports in host header
Previously, it was possible that the host header looks
like domain.com:4444:4444 - obviously a bug.
2013-06-10 18:15:25 +02:00
kybernetikos
808e1761ef Make the proxy request use the correct protocol (http/https).
I discovered that the proxy request was using http even when it
was proxying to an https port / url.  This is because we didn't pass
the https parameter through in the proxyRequest method.
2013-06-10 16:41:13 +01:00
Rob Wu
59d5bc6043 Set Host header based on actual input
Fixes #1
2013-03-30 17:40:54 +01:00
Rob W
ac0cced2f5 Updated README and description 2013-01-05 12:59:57 +01:00
Rob W
08791a11ed Updated demo: Redirect loop detection 2013-01-05 11:55:25 +01:00
Rob W
f22a2161cf Update package.json - v0.1.1 2013-01-05 11:14:46 +01:00
Rob W
407ba84a10 Avoid duplicate Access-Control-Expose-Headers 2013-01-05 11:05:32 +01:00
Rob W
792406d445 Added .gitignore 2013-01-05 00:07:29 +01:00
Rob W
eb5c57e729 Better description for non-proxied requests 2013-01-04 23:59:52 +01:00
Rob W
098f425d0a Improved demo, optimized server.js for Heroku 2013-01-04 23:31:13 +01:00
Rob W
051858b480 Location -> X-Location
xhr.getResponseHeader('Location') gives:
> Refused to get unsafe header "Location"
2013-01-04 23:16:38 +01:00
Rob W
204edda774 Clean-up of unused methods 2013-01-04 23:00:27 +01:00
Rob W
968f8439b0 Added demo; Add original status at 333 redirects 2013-01-04 22:55:16 +01:00
Rob W
544a52b0ff Fix for 3xx redirects; Disabled credentials 2013-01-04 22:46:01 +01:00
Rob W
7e198f7455 Updated package.json 2013-01-03 23:15:46 +01:00
Rob W
495a99ebde Docs update, added CORS to some responses. 2013-01-03 22:34:49 +01:00
Rob W
8a27a896d4 Detect port from environment 2013-01-03 21:26:03 +01:00
Rob W
10ce9a01e9 Added engine requirement node >= 0.6.6, npm >= 1.1 2013-01-03 21:11:19 +01:00
Rob W
2cf2300afb More documentation and options. 2013-01-03 20:56:25 +01:00
Rob W
b7ba441712 Updated README 2013-01-03 18:55:36 +01:00
Rob W
8a367bda4b CORS Anywhere - Initial commit 2013-01-03 18:46:50 +01:00