node-reqwest
v0.0.15
Published
Node.js bindings for reqwest - Rust HTTP client library
Maintainers
Readme
node-reqwest
Node.js bindings for reqwest - Rust HTTP client library. This library provides support for system proxy and trusted system CA certificates without additional configuration. The build is made in a fashion that allows usage by Electron-based applications.
Why you want to use this library?
- DNS resolution using recursive DNS resolver
https://github.com/hickory-dns/hickory-dns instead of
non-recursive https://github.com/c-ares/c-ares used by Node.js
(and Undici) which crashes Electron on Windows if you try
to resolve nonexistent domain
fetch('http://example.lan') - System CA certificates are used by default without additional libraries like https://www.npmjs.com/package/win-ca and https://www.npmjs.com/package/mac-ca
- System proxy is used by default, while it is not obtainable with Node.js and in Electron you have to use very complex interface https://www.electronjs.org/docs/latest/api/session#sesresolveproxyurl
- Socks proxy is supported out of the box
- HTTP/2 performance and support is much better than in Node.js
- Rustls https://github.com/rustls/rustls is used for TLS
Usage
This library provides an Agent that is fully compatible with the
undici.Dispatcher interface. This allows it to be used as a global
dispatcher for fetch or with other undici-compatible APIs.
import { Agent } from 'node-reqwest';
import { setGlobalDispatcher } from 'undici';
// Create an agent with system proxy enabled (default)
const agent = new Agent({
allowH2: true,
proxy: 'system'
});
setGlobalDispatcher(agent);
// Now all fetch calls will use reqwest under the hood
const response = await fetch('https://example.com');Install script
Warning: this package uses install script to download precompiled binary for the correct OS and architecture. All the binaries get attached to GitHub release. The releases are made immutable to prevent supply chain attacks.
