https://github.com/byte-foundry/adhoc-cors-proxy
Simple reliable node-based cors proxy to a specific target
https://github.com/byte-foundry/adhoc-cors-proxy
Last synced: 5 months ago
JSON representation
Simple reliable node-based cors proxy to a specific target
- Host: GitHub
- URL: https://github.com/byte-foundry/adhoc-cors-proxy
- Owner: byte-foundry
- Created: 2014-05-29T14:10:16.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-06-06T11:00:56.000Z (about 12 years ago)
- Last Synced: 2025-08-09T01:02:01.663Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 168 KB
- Stars: 2
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Ad-hoc cors proxy
=================
[](https://david-dm.org/byte-foundry/adhoc-cors-proxy)
**Simple reliable node-based cors proxy.**
```bash
$ corsproxy www.target.com -p 8080
proxy to http://www.target.com started on port 8080
```
Why *simple reliable*? Because it just assembles two well tested and actively maintained middlewares: [http-proxy](https://github.com/nodejitsu/node-http-proxy) and [cors](https://github.com/troygoode/node-cors/). It's a package you could have written yourself, but this one's ready to use with complete usage instructions (thanks to [docopt](http://github.com/docopt/docopt.coffee)).
## Installation
local testing
```bash
$ npm install adhoc-cors-proxy
```
global install
```bash
$ npm install -g adhoc-cors-proxy
```
## Usage
with local install
```bash
node bin [--port=] [--origin=] [--credentials]
node bin -h | --help | --version
```
with global install
```bash
corsproxy [--port=] [--origin=] [--credentials]
corsproxy -h | --help | --version
```
### Options
```bash
-p , --port= Port number. [default: 9292]
--host= Host
-o , --origin= Restrict origin domain
-c, --credentials access-control-allow-credentials=true
```
Alternatively, the proxy can be configured entirely using environment variables. Check [the sources](https://github.com/byte-foundry/adhoc-cors-proxy/blob/master/bin/index.js#L21) for a better understanding of configuration priority.
## Production
I recommend using [Heroku](http://www.heroku.com)'s free tier or [pm2](https://github.com/Unitech/pm2) on a virtual-machine cloud-service.
## Development
You can hack into this package by installing [grunt](http://gruntjs.com)
```bash
$ npm install -g grunt-cli
```
Starting the server and specifying the target has a slightly different syntax:
```bash
$ grunt --target=http://www.target.com -p 8080
```
Jshint will check your code and the proxy will restart everytime the sources are modified.
## License
[MIT](http://louisremi.mit-license.org)