Giter Club home page Giter Club logo

cors-proxy's Introduction

corsproxy

standalone CORS proxy

Build Status Dependency Status devDependency Status

NPM

Setup

npm install -g corsproxy
corsproxy
# with custom port: CORSPROXY_PORT=1234 corsproxy
# with custom host: CORSPROXY_HOST=localhost corsproxy
# with debug server: DEBUG=1 corsproxy
# with custom payload max bytes set to 10MB (1MB by default): CORSPROXY_MAX_PAYLOAD=10485760 corsproxy

Docker

It is also possible to run the cors proxy in a docker container:

# Build image
docker build -t corsproxy .

# Run container
docker run -p 1337:1337 --name corsproxy -d corsproxy

Usage

The cors proxy will start at http://localhost:1337. To access another domain, use the domain name (including port) as the first folder, e.g.

By default the cors proxy will only answer requests sent to localhost. To use another domain (e.g. machine name) set an enviroment variable CORSPROXY_HOST to the required value before launching.

License

MIT

cors-proxy's People

Contributors

aljungberg avatar cesine avatar daleharvey avatar denis-pakizh avatar denispakizh avatar furikuri avatar gingermusketeer avatar gr2m avatar janl avatar ksheedlo avatar rmetcalf9 avatar rocwind avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cors-proxy's Issues

Unsure of How Exactly to Use Corsproxy

Hi there,

I managed to get corsproxy to work to load wikipedia inside of an object but don't understand how I can use it to load another site like Google. I've looked everywhere I can and cannot seem to come up with a solution. I would preferably like to load Google inside of an object but any other way to load it would be good to.

Thanks

Throws exception when following example instructions

Excellent tool, but I have some issues with usage:

Starting from command prompt:

corsproxy
-bash: corsproxy: command not found

Created example file cors-proxy.js:

var cors_proxy = require("corsproxy");
var http_proxy = require("http-proxy");
http_proxy.createServer(cors_proxy).listen(1234);

Starting example file with:

node cors-proxy.js 

Opening URL http://localhost:1234/www.google.com results in:

node_modules/http-proxy/lib/http-proxy/index.js:119
    throw err;
          ^
Error: Must provide a proper URL as target
    at ProxyServer.<anonymous> (/Users/perqa/Workspace/project/node_modules/http-proxy/lib/http-proxy/index.js:68:35)
    at Server.closure (/Users/perqa/Workspace/project/node_modules/http-proxy/lib/http-proxy/index.js:125:43)
    at Server.emit (events.js:98:17)
    at HTTPParser.parser.onIncoming (http.js:2113:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:122:23)
    at Socket.socket.ondata (http.js:1971:22)
    at TCP.onread (net.js:528:27)

The only way I got it working as expected was:

node node_modules/corsproxy/bin/index.js 
CORS Proxy started on 127.0.0.1:9292

What is wrong here, do you think?

cors headers allowed as command-line option?

It was trivial to modify

var allowedHeaders = [
in my case to add X-Transmission-Session-Id, but maybe it'd be cool to allow a flag like --additional-headers=['foo', 'bar'] when running this so anyone could specify extra headers they need. It doesn't look like it'd require much re-plumbing, but I've not worked tons with Node.

Here's the code in question:
lib/add-cors-headers.js

module.exports = function addCorsHeaders (request, reply) {
  var allowedHeaders = [
    'authorization',
    'content-length',
    'content-type',
    'if-match',
    'if-none-match',
    'origin',
    'x-requested-with'
  ]

Use with webpack

When I am poroxying my reactjs application started using webpack, I encounter issue to proxy it correctly.

You can test it using the sample project here : https://github.com/mxstbr/react-boilerplate

This will throw errors when trying to access http://localhost:1337/localhost:3000 from your browser :

- 2016-10-19 02:27:52.315 localhost:3001:19 GET http://localhost:1337/reactBoilerplateDeps.dll.js 
- 2016-10-19 02:27:52.418 localhost:3001:19 GET http://localhost:1337/main.js 502 (Bad Gateway)

image

Is there any way to fix this using CORS-Proxy ?

License

How is CORS-proxy licensed?

Accessing proxy via browser kills the daemon

While I completely understand that access from the browser doesn't work for a variety of reasons, it's still a touch worrisome that a malicious user who sees I'm using corsproxy could kill it simply by navigating to the URL in the browser.

It's probably a simple patch to handle the error gracefully so I'll submit it when the need arises, but I figure this should be brought to your attention either way.

Solid product otherwise, kudos!

Corsproxy throws

I just ran corsproxy and navigated to http://localhost:1337/daleharvey.iriscouch.com/grocery/1323263686230-12546e1c-0087-4774-91fc-1407f2ad9306. Corsproxy throws the following.

150504/162029.577, [log,info], data: CORS Proxy running at:http://arch:1337
proxy to http://daleharvey.iriscouch.com/grocery/1323263686230-12546e1c-0087-4774-91fc-1407f2ad9306
Debug: internal, implementation, error 
    Error: "name" and "value" are required for setHeader().
    at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:333:11)
    at Object.internals.transmit (/usr/lib/node_modules/corsproxy/node_modules/hapi/lib/transmit.js:251:25)
    at /usr/lib/node_modules/corsproxy/node_modules/hapi/lib/transmit.js:169:26
    at Function.internals.Auth.response (/usr/lib/node_modules/corsproxy/node_modules/hapi/lib/auth.js:381:16)
    at /usr/lib/node_modules/corsproxy/node_modules/hapi/lib/transmit.js:139:25
    at internals.Response._streamify (/usr/lib/node_modules/corsproxy/node_modules/hapi/lib/response.js:488:12)
    at internals.Response._marshal (/usr/lib/node_modules/corsproxy/node_modules/hapi/lib/response.js:434:21)
    at /usr/lib/node_modules/corsproxy/node_modules/hapi/lib/transmit.js:119:18
    at /usr/lib/node_modules/corsproxy/node_modules/hapi/lib/transmit.js:536:20
    at Object.exports.parallel (/usr/lib/node_modules/corsproxy/node_modules/hapi/node_modules/items/lib/index.js:47:9)

Getting Server Error (500)

I've been successfully using corsproxy and then all of a sudden (about 1-2 months ago) I started getting this error:

An error has occurred: {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect"}

I still can't figure out what is causing it. I've tried starting the proxy on various ports with no success.

CORS-Proxy https example

The node-http-proxy readme has a section on how to configure the proxy to use HTTPS. It involves passing in an options object with some configuration.

How would you pass in the options object and the cors proxy handler?

Connection Refused

I have installed corsproxy via npm and ran the corsproxy command to start the server but it doesn't look like its working. I get a ERR_CONNECTION_REFUSED on my browser. Any help? I also cant connect via telnet

Chinese garbage problem

I am a Chinese developer. In use, I met a Chinese distortion of the issue.
Use this proxy to access most of the site does not garbled. However, when I asked some of the url, the server returns a Chinese distortion, for use of other cross-border proxy test, and did not return garbled.
The url is: http: // localhost: 1337 / news.hpu.edu.cn / news / contents / 544 / 118139.html
I'm not sure this is what causes.
My operating system is ubuntu16.04, nodejs version is 4.2.6, the test browser is chromium

thanks!

Bad request on url which used to work

When I try to access the following url :
http://localhost:9292/static.moviecrow.com/marquee/thaandavam-reviews-from-fdfs-viewers/8811_thumb_665.jpg
I get the following error message :
`ERROR

The request could not be satisfied.

Bad request.
Generated by cloudfront (CloudFront)
Request ID: PeNEDZYGuZR9ZUUDcSzGG9THp9LO2SfTCKUxDIxLv56_tPXs_8s-6A==`

The previous version of your code worked fine, but the node package version is 1.0.0 for both, so it's impossible to come back to old version.

Great work though, but if it was possible to have a package for the older version, it would be great !

corsproxy throwing `headers already sent` error

Run corsproxy and type http://localhost:9292/localhost:5984. After like 5 seconds corsproxy throws this:

http.js:733
    throw new Error('Can\'t render headers after they are sent to the client.'
          ^
Error: Can't render headers after they are sent to the client.
    at ServerResponse.OutgoingMessage._renderHeaders (http.js:733:11)
    at ServerResponse.writeHead (http.js:1150:20)
    at Socket.proxyError (/usr/lib/node_modules/corsproxy/node_modules/http-proxy/lib/node-http-proxy/http-proxy.js:193:9)
    at Socket.g (events.js:175:14)
    at Socket.EventEmitter.emit (events.js:117:20)
    at net.js:830:16
    at process._tickCallback (node.js:415:13)

not sure why is this.

Issue options.host and options.port or options.target are required

Hi, thanks for this cors proxy.

I'm struggling to get it to work.
When I start the proxy with corsproxy and go to 127.0.0.1:9292/localhost:5000 in the browser it stops the proxy and i get this error http://cl.ly/image/0q2W2o1n3H1d.
My localhost:5000 is just a node-static server.
In the browser, the content loads and then freezes because the corsproxy is not proxying anymore.

I tried with a new angular app but still get the error. Any ideas?
Thanks!!

Default PORT changed

Just a note to signal that the default port changed in your code from 9292 to 1337. The readme would need to be updated in consequence, and maybe warn users who update the package (took me a few time to understand the problem). Thanks !

Can't render headers after they are sent to the client

We see this bug all the time in PouchDB when we set this up as a proxy to CouchDB. It's an intermittent in our unit tests:

http.js:731
    throw new Error('Can\'t render headers after they are sent to the client.'
    ^
Error: Can't render headers after they are sent to the client.
    at ServerResponse.OutgoingMessage._renderHeaders (http.js:731:11)
    at ServerResponse.writeHead (http.js:1148:20)
    at ClientRequest.proxyError (/Users/nolan/workspace/pouchdb/node_modules/http-proxy/lib/node-http-proxy/http-proxy.js:213:9)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.EventEmitter.emit (events.js:95:17)
    at Socket.socketOnData (http.js:1588:9)
    at TCP.onread (net.js:527:27)

Apparently it was fixed upstream (http-party/node-http-proxy#388), but this module still relies on an older version of http-proxy, so unfortunately we don't get the benefit.

I'm guessing this could be solved by updating it to work with http-proxy ^1.1.4?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.