Skip to content

Random port appended in OmniAuth callback? #227

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

Closed
ghost opened this issue Apr 10, 2012 · 3 comments
Closed

Random port appended in OmniAuth callback? #227

ghost opened this issue Apr 10, 2012 · 3 comments

Comments

@ghost
Copy link

ghost commented Apr 10, 2012

I am using node-http-proxy with the following code:

var railsProxy = new httpProxy.HttpProxy({ 
  target: { 
    host: 'localhost', 
    port: CONFIG.RAILS_PORT,
  }
});

var socketProxy = new httpProxy.HttpProxy({ 
  target: {
    host: 'localhost', 
    port: CONFIG.SOCKET_PORT,
  }
});

var reverseProxy = http.createServer(function(req, res) { 
  switch(req.headers.host) { 
    case "socket.mysite.com":
      socketProxy.proxyRequest(req, res);
      break;
    default: 
      railsProxy.proxyRequest(req, res);
      break;
  }
});

Currently, this is breaking my omniauth for facebook. When I click "login with facebook" on my site,

I am 404'ed with the following url in my url bar:

http://mysite.com:49592/users/auth/facebook/callback?code=AQBab4LR3HFBEs9Oo0yGqR-RbZHDTymeUJwmyl9Fg1MW9DBvwBIbH_vsECR5jcq_excWaCZGU-WiEUv8hPfZ_C9FT0xHZ28CMueDWAtb3_aZWduRjGMvuSDey_DPNi03O7K62S2mthQ6_qWP5GCGU-jZCaYg1Hrn1RXZxowuhCxz-yrlSxP27upshnsWwZWFY9I#_=_

Another attempt at this will produce port 49602. Which is extremely weird as I was testing my site on http://mysite.com. Where does the random port come from?

I have decided to test what is causing this, so I wget to see the url redirection:

$ wget http://mysite.com/users/auth/facebook
--2012-04-09 23:54:48--  http://mysite.com/users/auth/facebook
Resolving mysite.com... 127.0.0.1
Connecting to mysite.com|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://graph.facebook.com/oauth/authorize?response_type=code&client_id=258465037564047&redirect_uri=http%3A%2F%2Fmysite.com%3A49689%2Fusers%2Fauth%2Ffacebook%2Fcallback&scope=email%2Coffline_access [following]
--2012-04-09 23:54:48--  https://graph.facebook.com/oauth/authorize?response_type=code&client_id=258465037564047&redirect_uri=http%3A%2F%2Fmysite.com%3A49689%2Fusers%2Fauth%2Ffacebook%2Fcallback&scope=email%2Coffline_access
Resolving graph.facebook.com... 66.220.147.27
Connecting to graph.facebook.com|66.220.147.27|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://www.facebook.com/dialog/permissions.request?app_id=258465037564047&display=page&next=http%3A%2F%2Fmysite.com%3A49689%2Fusers%2Fauth%2Ffacebook%2Fcallback&response_type=code&perms=email%2Coffline_access&fbconnect=1 [following]
--2012-04-09 23:54:48--  https://www.facebook.com/dialog/permissions.request?app_id=258465037564047&display=page&next=http%3A%2F%2Fmysite.com%3A49689%2Fusers%2Fauth%2Ffacebook%2Fcallback&response_type=code&perms=email%2Coffline_access&fbconnect=1
Resolving www.facebook.com... 66.220.149.18
Connecting to www.facebook.com|66.220.149.18|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://www.facebook.com/common/browser.php [following]
--2012-04-09 23:54:48--  http://www.facebook.com/common/browser.php
Connecting to www.facebook.com|66.220.149.18|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13997 (14K) [text/html]
Saving to: `facebook'

100%[==========================================================================>] 13,997      --.-K/s   in 0.04s   

If I remove the port from the url, I am actually able to login. Anyone know why I am seeing this random port being inserted into my url?

@indexzero
Copy link
Member

Not sure. Could be a Facebook issue behind proxies.

@indexzero
Copy link
Member

This looks related to #341 and you're getting the ephemeral port.

trvsdnn pushed a commit to trvsdnn/node-http-proxy that referenced this issue May 14, 2013
`req.remotePort' returns the ephemeral port, which is not useful.
node v0.10.0 added `req.localPort' which returns what we want, but
we want to maintain backwards compatibility. Fixes http-party#341 & http-party#227
indexzero pushed a commit that referenced this issue Dec 27, 2013
`req.remotePort' returns the ephemeral port, which is not useful.
node v0.10.0 added `req.localPort' which returns what we want, but
we want to maintain backwards compatibility. Fixes #341 & #227
@jcrugzz
Copy link
Contributor

jcrugzz commented Oct 30, 2015

No longer an issue.

@jcrugzz jcrugzz closed this as completed Oct 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants