Skip to content

Dev Server Proxy wrong x-forwarded-port header value #1088

@xelaris

Description

@xelaris

Since version v3.29.0 we are experiencing a problem in our dev setup, due to a wrong port being passed by the proxy in the x-forwarded-port header. Before 3.29 it was correctly set to 3000 (respectively the port the dev server is listening at). Since 3.29 it seems to be set to client port?

Image

This seems to be related to #1051.

The previous implementation set the header like this:

    if (!proxyReq.hasHeader('x-forwarded-port')) {
      const localPort = req?.socket?.localPort
      if (localPort) {
        proxyReq.setHeader('x-forwarded-port', req.socket.localPort)
      }
    }

The new implementation does not seem to contain anything comparable.

Adding something like webRequest.headers.set('x-forwarded-port', req.socket.localPort); in

const webRequest = new NodeRequest({ req, res })
const webResponse = await fetchAddress(address, webRequest)
would probably fix this. I don't have enough insights though to solve it "the right way".

The x-forwarded-host header is affected in the same way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions