GitHub Documentation

Cant get player's ip when use colyseus/proxy

  • I use colyseus/proxy for my game.
    If I use this code to get ip. I only get ip of proxy of cloud. Not client's ip.

    async onAuth(client: Client, options: any, request: http.IncomingMessage) {
    const ip = request.headers['x-forwarded-for'] || request.connection.remoteAddress;

    Anyone has same problem ? And how to solve this problem ?

  • administrator

    Hi @ttcong194, thanks for pointing out!

    Can you upgrade @colyseus/proxy to version 0.12.4? I've just pushed a fix for this, now forwarding properly the "x-forwarded-for" header:

    Please let me know if that works for you! Cheers!

  • @endel thanks for replying me.
    I update new proxy use this command npm i @colyseus/proxy@latest. And make sure last version is 0.12.4.
    But when I check file proxy.js again at /node_modules/@colyseus/proxy/proxy.js, I cant find line req.headers['x-forwarded-for'] = req.connection.remoteAddress;

    server.on('upgrade', function (req, socket, head) {
        var proxy = getProxy(req.url);
        if (proxy) {
  , socket, head);
        else {
            console.error("No proxy available!", processIds);

    is that any wrong with me ?

  • administrator

    Oops, you're right @ttcong194, for some reason the pre-publishing script did not run before publishing the NPM package... It has been fixed now on 0.12.5! Sorry about that

  • @endel . it's done and work for me. thanks for your support. You're so nice.


© 2021 Lucid Sight, Inc