You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I'm testing this module to be able to have single api called by socket and by http, but I'm getting this error:
ERROR TypeError: Cannot read property 'remoteAddress' of undefined at forwarded (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/forwarded/index.js:31:35) at alladdrs (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/proxy-addr/index.js:57:15) at proxyaddr (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/proxy-addr/index.js:231:15) at IncomingMessage.ip (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/request.js:351:10) at getip (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/morgan/index.js:466:14) at logger (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/morgan/index.js:107:26) at Layer.handle [as handle_request] (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:317:13) at /Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:335:12) at next (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:275:10) at app.use (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/run-middleware/index.js:16:5) at Layer.handle [as handle_request] (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:317:13) at /Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:335:12) +6ms 500 '<h1>Cannot read property 'remoteAddress' of undefined</h1>\n<h2></h2>\n<pre></pre>\n' { 'X-Powered-By': 'Express', 'x-powered-by': 'Express' }
The text was updated successfully, but these errors were encountered:
I thinks it's because (if you take a look at the index.js of the module, function createRes), the Response object "emulated" by app.runMiddleware doesn't have a res.connection property. So if somewhere in a middleware crossed by the path given, you use req.connection.remoteAdress, connection will be undefined and that will cause this error.
If i'm not mistaken, try to run the same path inside a request middleware with req.runMiddleware. In this case, the req and res normal object will be used, and you shouldn't have this error because req.connection exists.
To solve your problem, you can try to add connection property manually in the options argument app.runMiddleware('path/to/your/request', { connection: { remoteAddress: /fakeAdress/ } }, /callback/)
Hello. I'm testing this module to be able to have single api called by socket and by http, but I'm getting this error:
ERROR TypeError: Cannot read property 'remoteAddress' of undefined at forwarded (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/forwarded/index.js:31:35) at alladdrs (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/proxy-addr/index.js:57:15) at proxyaddr (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/proxy-addr/index.js:231:15) at IncomingMessage.ip (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/request.js:351:10) at getip (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/morgan/index.js:466:14) at logger (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/morgan/index.js:107:26) at Layer.handle [as handle_request] (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:317:13) at /Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:335:12) at next (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:275:10) at app.use (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/run-middleware/index.js:16:5) at Layer.handle [as handle_request] (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:317:13) at /Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/Users/osoverflow/IdeaProjects/domitai/dokku/node_modules/express/lib/router/index.js:335:12) +6ms 500 '<h1>Cannot read property 'remoteAddress' of undefined</h1>\n<h2></h2>\n<pre></pre>\n' { 'X-Powered-By': 'Express', 'x-powered-by': 'Express' }
The text was updated successfully, but these errors were encountered: