You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, with `browser: 'chrome_137'`, the default request would normally include Chrome-like `sec-ch-*`, `sec-fetch-*`, `user-agent`, `accept`, and `accept-language` headers. With `disableDefaultHeaders: true`, those browser preset headers are skipped, while transport headers like `host` and `accept-encoding` may still be present.
719
771
720
-
```ts
721
-
awaitfetch('https://example.com', {
722
-
headers: [
723
-
['x-lower', 'one'],
724
-
['X-Mixed', 'two'],
725
-
],
726
-
});
727
-
```
772
+
### exact header order
728
773
729
-
### exact original header names on the wire
774
+
Use tuples when header order matters.
730
775
731
-
Use this only if you really need exact casing / spelling preservation:
776
+
Tuple headers also preserve the original header names exactly as you wrote them on the wire:
732
777
733
778
```ts
734
779
awaitfetch('https://example.com', {
735
-
disableDefaultHeaders: true,
736
-
keepOriginalHeaderNames: true,
737
780
headers: [
738
781
['x-lower', 'one'],
739
782
['X-Mixed', 'two'],
740
783
],
741
784
});
742
785
```
743
786
787
+
For example, this will preserve both the tuple order and the exact `x-lower` / `X-Mixed` casing you passed.
788
+
744
789
### lower-level transport tuning
745
790
746
791
If a browser preset gets you close but not all the way there:
@@ -767,14 +812,66 @@ Use these only when:
767
812
- you are comparing transport behavior
768
813
- you want to debug fingerprint mismatches
769
814
815
+
### mTLS and custom CAs
816
+
817
+
Use `tlsIdentity` for client certificate authentication and `ca` for a custom trust store:
818
+
819
+
```ts
820
+
import { fetch } from'node-wreq';
821
+
import { readFileSync } from'node:fs';
822
+
823
+
awaitfetch('https://mtls.example.com', {
824
+
tlsIdentity: {
825
+
cert: readFileSync('./client-cert.pem'),
826
+
key: readFileSync('./client-key.pem'),
827
+
},
828
+
ca: {
829
+
cert: readFileSync('./ca.pem'),
830
+
includeDefaultRoots: false,
831
+
},
832
+
});
833
+
```
834
+
835
+
PKCS#12 / PFX identities are also supported:
836
+
837
+
```ts
838
+
awaitfetch('https://mtls.example.com', {
839
+
tlsIdentity: {
840
+
pfx: readFileSync('./client-identity.p12'),
841
+
passphrase: 'secret',
842
+
},
843
+
ca: {
844
+
cert: readFileSync('./ca.pem'),
845
+
includeDefaultRoots: false,
846
+
},
847
+
});
848
+
```
849
+
770
850
### compression
771
851
772
852
Compression is enabled by default.
773
853
854
+
That includes `gzip`, `br`, `deflate`, and `zstd` response decoding when the server supports them.
855
+
774
856
Disable it if you need stricter control over response handling:
775
857
776
858
```ts
777
859
awaitfetch('https://example.com/archive', {
778
860
compress: false,
779
861
});
780
862
```
863
+
864
+
### DNS controls
865
+
866
+
Use `dns.hosts` to pin hostnames to specific IPs, or `dns.servers` to send lookups through specific nameservers:
0 commit comments