Commit Graph

39 Commits

Author SHA1 Message Date
Rob Wu
a21400378c Version 0.4.2
- Reject invalid URLs earlier instead of trying to continue with the
  request (and failing anyway).
- Explicitly close the response when an error occurs for Node 13+.
- Update tests to cover up to Node 14 (was up to 9).
2020-05-02 17:58:26 +02:00
Rob Wu
2ee31471ce Version 0.4.1
- Add ability to rate-limit/block requests by origin (#45).
- Avoid crashing on invalid HTTP status codes (#95).
- Support and test coverage for latest Node.js versions (up to 9).
- Support `Access-Control-Max-Age` via `corsMaxAge` option.
- Listen on `0.0.0.0:8080` by default instead of `127.0.0.1:8080`.
  (use `HOST` and `PORT` environment variables to override this).
- Update gTLD list.
2017-12-01 14:05:34 +01:00
Rob Wu
b419acc6e5 Explicitly list all files for the npm package 2017-12-01 14:05:25 +01:00
Rob Wu
6741f810f9 Remove engines.npm (#92)
NPM 5.5.1 is not compatible with Node.js 9.1.0.
Let's use the npm that ships with node.
2017-11-11 01:32:29 +01:00
Rob Wu
ded44cb5d0 Upgrade supertest + nock to recent version
The most recent version that was explicitly marked as compatible with
Node.js 0.10.x
2017-07-13 17:32:45 +02:00
Rob Wu
81ed058784 Update mocha to ^3.4.2
to unlock goodies such as --inspect / --inspect-brk
2017-07-13 12:45:44 +02:00
Rob Wu
6c4234f2b3 Add rate-limiting functionality #45
- Add checkRateLimit option to the API.
- Extend the default server.js with environment variables
  CORSANYWHERE_WHITELIST (re-using originWhitelist) and
  CORSANYWHERE_RATELIMIT (using the new checkRateLimit option)
  to make it easy to enforce usage limits.
- Document that Heroku doesn't want open proxies.
2016-05-31 00:52:26 +02:00
Rob Wu
bb4293a74d Version 0.4.0
- CI & 100% test coverage
- Do not crash when a malformed HTTP response is received.
- Remove getHandler (its documented form was broken anyway).
- Allow custom help file to be set.
- Add option to redirect same-origin requests instead of proxying them.
2016-03-19 19:17:18 +01:00
Rob Wu
24db52500f Remove requiresPort dependency
location.host is directly parsed from the full URL, so the
"concatenate host and port" branch was never taken.
2016-02-26 12:58:11 +01:00
Rob Wu
f9af03e762 Add Travis and test coverage
Notes:
- npm run test also runs the memory tests, which might be flaky on
  some systems.
- npm run test-coverage only runs the unit tests (it can't run the
  memory test anyway because the memory tests create a Node child
  process, and istanbul cannot cover that).
2016-02-26 12:38:59 +01:00
Rob Wu
0872577729 Enforce a consistent coding style using eslint 2016-02-26 12:31:35 +01:00
Rob Wu
e8f0e64168 Version 0.3.0
- Support proxying through proxy (`getProxyForUrl` option, defaulting to
  proxy configuration from the environment variables, see
  https://github.com/Rob--W/proxy-from-env) (#37).
- Update gTLD list.
2016-02-19 00:48:45 +01:00
Rob Wu
8568c06b17 Support proxying through a proxy - #37
Automatically respects proxy headers from environment variables,
using https://github.com/Rob--W/proxy-from-env
2016-02-19 00:22:20 +01:00
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
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
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
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
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
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
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
8caf221cc2 Version 0.1.7 2013-08-30 11:43:11 +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
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
ba185f5ec8 Version bump to 0.1.3 2013-06-10 18:38:59 +02: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
f22a2161cf Update package.json - v0.1.1 2013-01-05 11:14:46 +01:00
Rob W
7e198f7455 Updated package.json 2013-01-03 23:15:46 +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
8a367bda4b CORS Anywhere - Initial commit 2013-01-03 18:46:50 +01:00