EDIT: There's an additional issue with the address I'm trying to reach. Until that's resolved, this question is moot for me. Leaving it up for discussion only.
I have two macbooks, personal and work. My work mac has a VPN connection to my company network that is tied to the hardware itself, so I can't simply use the same credentials on my personal mac.
To access my company intranet at https://intranet.mycompany.com from my personal mac, I first ssh to my work mac from my personal mac:
ssh my-username@work-mac.local -D 9999
then turn on Socks proxy for wifi in the Network system preference pane on my personal mac. I have the proxy server set to localhost:9999.
From there, I can access the intranet in my browser on my personal mac.
There's an REST endpoint on the intranet that I want to access from a node script on my personal mac. For example:
import fetch from 'node-fetch';
const response = await fetch('https://intranet.mycompany.com/api/todos/');
const body = await response.text();
but that results in ENOTFOUND intranet.mycompany.com.
I've also tried using socks-proxy-agent following their example like so:
const url = require('url');
const https = require('https');
const { SocksProxyAgent } = require('socks-proxy-agent');
const proxy = 'socks://localhost:9999';
console.log('using proxy server %j', proxy);
const endpoint = 'https://intranet.mycompany.com/api/todos/';
console.log('attempting to GET %j', endpoint);
const opts = url.parse(endpoint);
const agent = new SocksProxyAgent(proxy);
opts.agent = agent;
https.get(opts, function (res) {
console.log('"response" event!', res.headers);
res.pipe(process.stdout);
});
but also get ENOTFOUND intranet.mycompany.com. And in any case, what I really want is to just send all outbound traffic through the proxy without having to specify the endpoint each time.
Thoughts? Thanks!