curl-request icon indicating copy to clipboard operation
curl-request copied to clipboard

Interface not working

Open ghost opened this issue 5 years ago • 0 comments

I try to use interface option but it doesnt work. No error but gives me other interface's ip

var curl = new (require( 'curl-request' ))();

curl
.setOpt('interface', 'eth0')
.setHeaders([
    'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'
])
.get('www.wtfismyip.com/json')
.then(({statusCode, body, headers}) => {
    console.log(statusCode,body)
})
.catch((e) => {
    console.log(e);
});

It works on command tool with curl. I get the right ip with that command;

sudo curl -s http://www.wtfismyip.com/text --interface eth0

ghost avatar Jul 06 '20 13:07 ghost