1- import { fetch, FormData, File } from 'node-fetch-native';
1+ import { fetch, FormData, File } from 'node-fetch-native-with-agent';
2+ import { createAgent } from 'node-fetch-native-with-agent/agent';
23import { Models } from './models';
34
45type Payload = {
@@ -49,7 +50,7 @@ function getUserAgent() {
4950 // https://common-min-api.proposal.wintercg.org/#requirements-for-navigatoruseragent
5051 if (typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string') {
5152 ua += ` ${navigator.userAgent}`;
52-
53+
5354 // Older Node.js versions don't have `navigator.userAgent`, so we have to use `process.version`.
5455 } else if (typeof process !== 'undefined') {
5556 ua += ` Node.js/${process.version}`;
@@ -61,6 +62,8 @@ function getUserAgent() {
6162class Client {
6263 static CHUNK_SIZE = 1024 * 1024 * 5;
6364
65+ fetch = nodeFetch;
66+
6467 config = {
6568 endpoint: '{{ spec .endpoint }}',
6669 selfSigned: false,
@@ -102,6 +105,10 @@ class Client {
102105 * @returns {this}
103106 */
104107 setSelfSigned(selfSigned: boolean): this {
108+ if (typeof globalThis.EdgeRuntime !== 'undefined') {
109+ console.warn('setSelfSigned is not supported in edge runtimes.');
110+ }
111+
105112 this.config.selfSigned = selfSigned;
106113
107114 return this;
@@ -148,7 +155,8 @@ class Client {
148155 let options: RequestInit = {
149156 method,
150157 headers,
151- credentials: 'include'
158+ credentials: 'include',
159+ ...createAgent({ rejectUnauthorized: !this.config.selfSigned }),
152160 };
153161
154162 if (method === 'GET') {
0 commit comments