Skip to content

node-fetch-native/proxy - noProxy does not properly parse hosts with port #125

Open
@CS-JJ

Description

@CS-JJ

Environment

Node 21.6.1
node-fetch-native 1.6.4

Reproduction

Make any request specifying port in the url to a host that is on the noProxy list.

http_proxy = 10.0.0.1:3128
no_proxy = 10.10.10.10
await fetch('http://10.10.10.10:8001/healthz')

You should observe the host applying the proxy settings to the request instead of observing the specified no_proxy configuration

Describe the bug

The bypassProxy implementation does not check/parse the hostname from any port specification in the request.
This causes any requests to hosts in the no_proxy configuration using a specified port to have proxy configurations applied.

Suggested fix

host = host.split(':').at(0);

Additional context

There is an existing workaround to this issue by specifying the host with the port in the no_proxy variable
This would correctly bypass the proxy settings in the current implementation.

no_proxy=10.10.10.10:8001
fetch('10.10.10.10:8001/healthz') 

Logs

No response

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