Commit Graph

74 Commits

Author SHA1 Message Date
Rob Wu
440d2de180 Version 0.2.5
- Add setHeaders to replace request headers with a fixed value (#33).
2015-08-23 14:48:29 +02:00
Rob Wu
a2f0c05b24 Add more tests for setHeaders 2015-08-23 10:58:58 +02:00
Rob Wu
015627b3f4 setHeaders is a dict, not an array 2015-08-23 10:52:01 +02:00
Nikolay Derkach
c5a3877e6c add setHeaders option 2015-08-22 16:49:59 -07:00
Rob Wu
8429bb3c58 Version 0.2.4
- Add originBlacklist (#32) and originWhitelist (#24) options.
- Update gTLD list.
2015-08-16 01:12:12 +02:00
Rob Wu
c0048573e9 Update gTLD list 2015-08-16 01:11:11 +02:00
Rob Wu
837dee582c Add originBlacklist + originWhitelist
- originWhitelist resolves #24
- originBlacklist may help with #32
2015-08-16 01:05:26 +02:00
Rob Wu
7a138b36cc Version 0.2.3
Changes:
- Updated to node-http-proxy 1.11.1 from 1.3.0
- Add httpsOptions configuration to listen as a https server.
- Update gTLD list, and allow requests to unlisted TLDs if the
  scheme is explicitly set (#14).
- Added loads of unit tests and automatic memory leak tests.
2015-05-09 11:26:23 +02:00
Rob Wu
f8f718ead8 Add tests for memory leaks
Using the performNRequests, I collected the following statistics
before choosing the maximum allowed "leaked" memory.

Node.js 0.12.2,
Using the http module ('use-http-instead-of-cors-anywhere'):

Memory usage delta: 132800 (100 requests of 50 kb each, 250ms)
Memory usage delta: 110144 (100 requests of 1 kb each, 172ms)
Memory usage delta: 709936 (1000 requests of 1 kb each, 902ms)
Memory usage delta: 865104 (10000 requests of 1 kb each, 7073ms)
Memory usage delta: 930416 (100000 requests of 1 kb each, 62856ms)

Using CORS Anywhere:

Memory usage delta: 356784 (100 requests of 50 kb each, 1004ms)
Memory usage delta: 355248 (100 requests of 1 kb each, 641ms)
Memory usage delta: 1326856 (1000 requests of 1 kb each, 3338ms)
Memory usage delta: 1462584 (10000 requests of 1 kb each, 21186ms)
Memory usage delta: 1473624 (100000 requests of 1 kb each, 211202ms)

Clearly, there is a small leak, but it is not proportional/linear
in terms of the number of requests, so the observed "leak" is probably
not an issue. Furthermore, the "leak" also occurs with the plain
http module.

After setting fixed limits, I ran the tests on Node.js 0.10.25 and
observed that the tests failed due to the too low limits, so I
incremented the limits (400 -> 550, 1500 -> 2000).
2015-05-09 11:23:27 +02:00
Rob Wu
0e594a2b03 Skip host check if scheme is explicitly set
Fixes https://github.com/Rob--W/cors-anywhere/issues/14

This allows CORS anywhere to be forwards-compatible with the surge
of new gTLDs.
2015-05-09 11:09:59 +02:00
Rob Wu
903f3d32dc Update TLD list. 2015-05-06 20:15:50 +02:00
Rob Wu
fbf3ce9255 Update copyright year to 2015 2015-05-06 20:15:50 +02:00
Rob Wu
19de080098 Move inline jshint directive to .jshintrc 2015-05-06 20:15:50 +02:00
Rob Wu
d437bc9225 Test that redirect headers are not set in response 2015-05-06 20:02:55 +02:00
Rob Wu
b5d601f823 Verify and update links to node-http-proxy 2015-05-06 19:53:57 +02:00
Rob Wu
024d540e7c Fix test expectations for xfwd 2015-05-06 19:46:58 +02:00
Rob Wu
2d84862546 Upgrade http-proxy to 1.11.1
All xfwd and tests fails with this change, but that's because the
tests themselves were incorrect (using port 80/443 instead of the
ephemeral ports created for the tests).
2015-05-06 19:19:21 +02:00
Rob Wu
f98705f27b Add test for proxy error 2015-05-06 18:40:04 +02:00
Rob Wu
e8202aa31f Add more xfwd tests (https+http & http+https) 2015-05-06 18:20:11 +02:00
Rob Wu
056cb446fe x-forwarded-port should match the request port.
Not the proxied one. These tests will now fail, but that's because
the current implementation is apparently incorrect.
2015-05-06 12:08:53 +02:00
Rob Wu
80da247827 Add httpsOptions option to create https.Server
Note: This does not work with the current version of node-http-proxy
and node 0.12.0 because req.connection.pair is not defined.
2015-05-06 12:07:31 +02:00
Rob Wu
1ee157fc0f Add unit tests 2015-05-05 22:37:20 +02:00
Rob Wu
f0bdb5ffd1 Remove manual leak test
webkit-devtools-agent (tested with 0.2.4 and 0.3.1) is incompatible with
Node 0.12.0. The manual test adds no value at this point, so it has been
removed, including the dependencies (webkit-devtools-agent).
2015-05-05 18:08:33 +02:00
Rob Wu
6b54191df9 0.2.2 - Expose every response header #12 2014-10-05 16:14:49 +02:00
Rob Wu
4343044781 Default to https for the CORS API.
Heroku uses Strict Transport Security (HSTS), which forces that all
requests to *.herokuapp.com must use HSTS. However. Chrome cannot read
the CORS response after a HSTS redirect due to https://crbug.com/387198.

Since the request is going to be redirected to https anyway, the demo
and the documentation will use https by default.
2014-08-29 19:17:52 +02:00
Rob Wu
0745b894c6 0.2.1 - Update URL parsing logic (fixes #9) 2014-08-29 16:30:50 +02:00
Rob Wu
c78854e4cf 0.2.0 - upgraded to node-http-proxy 1.3.0
Upgrading fixes the issue that the server crashes when the request
times out (ETIMEDOUT).
2014-08-27 20:16:46 +02:00
Rob Wu
90d81e7033 Update TLD list 2014-08-25 13:43:13 +02:00
Rob Wu
bd9af5849f Upgrade from http-proxy 0.10.x to 1.3.0 2014-08-25 13:39:25 +02:00
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