mirror of
https://github.com/langgenius/dify.git
synced 2026-11-13 14:51:39 +08:00
21 lines
681 B
TypeScript
21 lines
681 B
TypeScript
import type { Dispatcher } from 'undici'
|
|
|
|
export type FetchInit = RequestInit & {
|
|
dispatcher?: Dispatcher
|
|
tls?: { rejectUnauthorized: boolean }
|
|
}
|
|
|
|
export type FetchInitOptions = Readonly<{
|
|
insecure: boolean
|
|
dispatcher?: Dispatcher
|
|
}>
|
|
|
|
// Shared by src/plugins/http.ts and src/auth/device-api.ts: both send requests
|
|
// that may need TLS verification skipped and/or routed through a proxy dispatcher.
|
|
export function buildFetchInit(base: RequestInit, opts: FetchInitOptions): FetchInit {
|
|
const init: FetchInit = { ...base }
|
|
if (opts.insecure) init.tls = { rejectUnauthorized: false }
|
|
if (opts.dispatcher !== undefined) init.dispatcher = opts.dispatcher
|
|
return init
|
|
}
|