{"action":"created","issue":{"url":"https://api.github.com/repos/nodejitsu/node-http-proxy/issues/1126","repository_url":"https://api.github.com/repos/nodejitsu/node-http-proxy","labels_url":"https://api.github.com/repos/nodejitsu/node-http-proxy/issues/1126/labels{/name}","comments_url":"https://api.github.com/repos/nodejitsu/node-http-proxy/issues/1126/comments","events_url":"https://api.github.com/repos/nodejitsu/node-http-proxy/issues/1126/events","html_url":"https://github.com/nodejitsu/node-http-proxy/issues/1126","id":198123764,"number":1126,"title":"Must provide a proper URL as target : options are empty for some reason","user":{"login":"mbret","id":1911240,"avatar_url":"https://avatars.githubusercontent.com/u/1911240?v=3","gravatar_id":"","url":"https://api.github.com/users/mbret","html_url":"https://github.com/mbret","followers_url":"https://api.github.com/users/mbret/followers","following_url":"https://api.github.com/users/mbret/following{/other_user}","gists_url":"https://api.github.com/users/mbret/gists{/gist_id}","starred_url":"https://api.github.com/users/mbret/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbret/subscriptions","organizations_url":"https://api.github.com/users/mbret/orgs","repos_url":"https://api.github.com/users/mbret/repos","events_url":"https://api.github.com/users/mbret/events{/privacy}","received_events_url":"https://api.github.com/users/mbret/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-30T09:24:37Z","updated_at":"2016-12-30T09:44:43Z","closed_at":null,"body":"I'm using a simple proxy for web and socket and for some reason some of my request throw errors.\r\n\r\ninstead of having an object with { target: .., forward: ... } I got an empty withouth these two key. However I do have the \"secure\" key that I set while creating proxy object and I do have \"prependPath\".\r\n\r\nEx:\r\nFor most of my sockets request I have usually:\r\n```\r\n{ target:\r\n   Url {\r\n     protocol: 'https:',\r\n     slashes: true,\r\n     auth: null,\r\n     host: 'localhost:3001',\r\n     port: '3001',\r\n     hostname: 'localhost',\r\n     hash: null,\r\n     search: null,\r\n     query: null,\r\n     pathname: '/',\r\n     path: '/',\r\n     href: 'https://localhost:3001/' },\r\n  forward:\r\n   Url {\r\n     protocol: null,\r\n     slashes: null,\r\n     auth: null,\r\n     host: null,\r\n     port: null,\r\n     hostname: null,\r\n     hash: null,\r\n     search: '?EIO=3&transport=polling&t=1483089414416-48&sid=CyuT-vFAV_iKoec5AAAC',\r\n     query: 'EIO=3&transport=polling&t=1483089414416-48&sid=CyuT-vFAV_iKoec5AAAC',\r\n     pathname: '/socket.io/',\r\n     path: '/socket.io/?EIO=3&transport=polling&t=1483089414416-48&sid=CyuT-vFAV_iKoec5AAAC',\r\n     href: '/socket.io/?EIO=3&transport=polling&t=1483089414416-48&sid=CyuT-vFAV_iKoec5AAAC' },\r\n  secure: false,\r\n  prependPath: true }\r\n```\r\n\r\nFor some other I only got\r\n`{ secure: false, prependPath: true }`\r\n\r\nwhich is why the module throw error because of this check\r\n```\r\nif (!options.target && !options.forward) {\r\n   return this.emit('error', new Error('Must provide a proper URL as target'));\r\n}\r\n```\r\n\r\nHere is what I do on my server side\r\n\r\n```\r\napp.locals.proxy = httpProxy.createProxyServer({\r\n      secure: false\r\n});\r\n\r\napp.all(\"/remote-api/*\", function(req, res) {\r\n    req.app.locals.proxy.web(req, res, { target: req.app.locals.system.config.sharedApiUrl, forward: req.url });\r\n});\r\n\r\nserver.on('upgrade', function (req, socket, head) {\r\n    app.locals.proxy.ws(req, socket, head);\r\n});\r\n```\r\n\r\nMy stack is pretty simple and as I said, all my web request are ok, pretty much all sockets too. Only some of them fails."},"comment":{"url":"https://api.github.com/repos/nodejitsu/node-http-proxy/issues/comments/269751788","html_url":"https://github.com/nodejitsu/node-http-proxy/issues/1126#issuecomment-269751788","issue_url":"https://api.github.com/repos/nodejitsu/node-http-proxy/issues/1126","id":269751788,"user":{"login":"mbret","id":1911240,"avatar_url":"https://avatars.githubusercontent.com/u/1911240?v=3","gravatar_id":"","url":"https://api.github.com/users/mbret","html_url":"https://github.com/mbret","followers_url":"https://api.github.com/users/mbret/followers","following_url":"https://api.github.com/users/mbret/following{/other_user}","gists_url":"https://api.github.com/users/mbret/gists{/gist_id}","starred_url":"https://api.github.com/users/mbret/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbret/subscriptions","organizations_url":"https://api.github.com/users/mbret/orgs","repos_url":"https://api.github.com/users/mbret/repos","events_url":"https://api.github.com/users/mbret/events{/privacy}","received_events_url":"https://api.github.com/users/mbret/received_events","type":"User","site_admin":false},"created_at":"2016-12-30T09:44:43Z","updated_at":"2016-12-30T09:44:43Z","body":"After some digging, only the web socket request from wss:// are in cause. What is strange is that my web page is working, connected and receiving socket connection."}}
{"actor":{"display_login":"mbret"}}