-
Notifications
You must be signed in to change notification settings - Fork 2k
Cannot read property 'protocol' of undefined #499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
👍 same issue. Probably solve it by passing an object to http.createProyx... pass this:
|
I don't think it fixes the actual problem. In my case I must change the The problem is here at lib/http-proxy/index.js line 76, there is I think it might be fixed by changing that code on line 76 to: cbl ? false : {emit:this.emit.bind(this), options:options} ...but that feels like a bad kind of workaround. |
Actually I don't see how that Although it's hard to understand how that could be possible -- nobody is using the code as it is documented? |
I've tested this workaround and it actually does fix the issue I'm having. However I don't know which would be best way to fix it in real life. Currently the passes implementation for web does not use anything else but |
Now that I rechecked the code for missing |
sorry for the late answer, i have been refactoring some code and might have inadvertedly broken something.. i'll look into it this afternoon |
Another issue I noticed was that the code is changing |
Using the last commit (f720e36) from the |
Hi. I'm seeing this issue and it seems to revolve around the following code in lib/http-proxy/index.js - line 77. All of the above code uses options, but the very last part references this.options, which is just an empty object.
If I change this.options to just options, it works on my end. |
The |
Yes this is a bug, currently filed in #510 |
Why is it closed? The workaround works, but the problem (simply running basic example code from main github page) remains unsolved (Node 0.11.13) |
I too am still having this problem |
Seeing this issue currently as well |
@theak can you post a new issue and give an example of the code you are using? This shouldn't be happening |
Ah, actually turned out to be an issue with how I was calling the code. Everything seems to be working fine now- false alarm 👍 |
Hello. I'm having exactly the same issue; I've cloned this repo & npm installed it. I've copy-pasted the sample from http://blog.nodejitsu.com/node-http-proxy-1dot0/ which looks like this: var httpProxy = require('http-proxy')
var proxy = httpProxy.createProxy();
var options = {
'foo.com': 'website.com:8001',
'bar.com': 'website2.com:8002'
}
require('http').createServer(function(req, res) {
proxy.web(req, res, {
target: options[req.headers.host]
});
}).listen(8000); When I visit http://localhost:8000 the following error occurs:
Perhaps I'm just having a bad day, but am I missing something? Thanks. |
@qmacro hey there was a typo in the blog post unfortunately that I just fixed. It should be a full URL prefixed with |
@qmacro Hi I was playing with the similar issue you came across. In my case when I entered my IP address the proxy generated the very same error. Than I included the my IPaddress in target options and redirected the request to some error server.
|
@webduvet That IP address issue took me some time to figure out. That was as tough one. |
README has this example for custom application logic (for caronte tree):
I'm getting these errors:
I am running node v0.10.20.
The text was updated successfully, but these errors were encountered: