hapijs / nes

WebSocket adapter plugin for hapi routes
Other
502 stars 87 forks source link

request.info.remoteAddress is always 127.0.0.1 in request handler #305

Closed air1one closed 4 years ago

air1one commented 4 years ago

Support plan

Context

What are you trying to achieve or the steps to reproduce?

With this simple hapi server with hapi/nes as plugin :

const Hapi = require('@hapi/hapi');
const Nes = require('@hapi/nes');

const server = new Hapi.Server({ port: 5000 });

const start = async () => {

    await server.register(Nes);
    server.route({
        method: 'GET',
        path: '/h',
        config: {
            id: 'hello',
            handler: (request, h) => {
                console.log(request.info.remoteAddress);
                return 'world!';
            }
        }
    });

    await server.start();
};

start();

Connecting like in the docs :

const Nes = require('@hapi/nes');

var client = new Nes.Client('ws://167.172.161.60:5000'); // change this with the server IP

const start = async () => {

    await client.connect();
    const payload = await client.request('hello');  // Can also request '/h'
    // payload -> 'world!'
};

start();

I always get a request.info.remoteAddress of 127.0.0.1 when connecting remotely.

What was the result you got?

Getting a request.info.remoteAddress of 127.0.0.1 when connecting remotely.

What result did you expect?

Getting a request.info.remoteAddress of the originating IP when connecting remotely.