dojo / core

:rocket: Dojo 2 - language helpers and utilities.
http://dojo.io
Other
213 stars 62 forks source link

Feature: request under Node.js can proxy like a browser #335

Open kitsonk opened 7 years ago

kitsonk commented 7 years ago

Enhancement

When working with request under Node.js, we should have similar functionality to what is available when running under XHR, in the sense of being able to configure the proxies in a particular way, but also supporting things like PAC configurations.

In order to do this we need to:

bryanforbes commented 7 years ago

We may want some of this to be a separate package. I started the PAC parser/resolver on Friday and it’s going to add dependencies on fibers (to be able to run dns.lookup synchronously in the PAC script), netmask, and ip.

kitsonk commented 7 years ago

Blah, yeah, I see the problem. What we have as a very light external run-time dependencies would suddenly become crowded and only be required by a smaller subset of users. I would be 👍 for breaking out as a separate package, with a replacement node request provider and additional modules for doing the proxy detection. I just don't know what we would name it.

bryanforbes commented 7 years ago

I think most of the code to actually use the proxy settings could still live in @dojo/core, but we could move the PAC and auto detection stuff to a separate package and users would do something like this:

import request from ‘@dojo/core/request’;
import { pac } from ‘@dojo/proxy’;

request(url, { proxy: pac(...) })
kitsonk commented 7 years ago

Would proxy be the right name, given that it would (at this point) only relate to running under Node.js or Electron? That is also one thing to check with fibres that it would work under Electron.