Skip to content
This repository was archived by the owner on May 30, 2025. It is now read-only.

Commit ab9b935

Browse files
committed
feat: add tls.servername option for fetch
1 parent cb1b216 commit ab9b935

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

packages/core/src/bridge/fetch/http.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ export function handleRequest(
5151
}
5252

5353
if (httpFn === https.request) {
54-
reqOptions.servername = reqOptions.hostname
54+
if (init.tls && init.tls.servername) {
55+
reqOptions.servername = init.tls.servername
56+
} else {
57+
reqOptions.servername = reqOptions.hostname
58+
}
5559
}
5660

5761
req = httpFn(reqOptions)

packages/core/src/bridge/fetch/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export interface RequestInit {
88
readTimeout?: number
99
headers?: Record<string, string>
1010
certificate?: Certificate
11+
tls?: {
12+
servername?: string
13+
}
1114
}
1215

1316
export type FetchBody = string | number | ArrayBuffer | Buffer | null

packages/v8env/src/fetch.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export interface FlyRequestInit extends RequestInit {
1616
pfx?: string | Buffer | Array<string | Buffer>
1717
passphrase?: string
1818
}
19+
tls?: {
20+
servername?: string
21+
}
1922
}
2023

2124
/**
@@ -40,7 +43,8 @@ export function fetch(req: RequestInfo, init?: FlyRequestInit): Promise<Response
4043
headers: (req.headers && req.headers.toJSON()) || {},
4144
timeout: init && init.timeout,
4245
readTimeout: (init && init.readTimeout) || 30 * 1000,
43-
certificate: init && init.certificate
46+
certificate: init && init.certificate,
47+
tls: init && init.tls
4448
}
4549
if (!req.bodySource) {
4650
bridge.dispatch("fetch", url, init, null, fetchCb)

0 commit comments

Comments
 (0)