瀏覽代碼

fix: missing headers in some cases (#18283)

Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: crazywoola <427733928@qq.com>
tags/1.3.0
hbprotoss 6 月之前
父節點
當前提交
28ffe7e3db
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 18 行新增7 行删除
  1. 18
    7
      web/service/fetch.ts

+ 18
- 7
web/service/fetch.ts 查看文件

getAbortController, getAbortController,
} = otherOptions } = otherOptions


const base
= isMarketplaceAPI
? MARKETPLACE_API_PREFIX
: isPublicAPI
? PUBLIC_API_PREFIX
: API_PREFIX
let base: string
if (isMarketplaceAPI)
base = MARKETPLACE_API_PREFIX
else if (isPublicAPI)
base = PUBLIC_API_PREFIX
else
base = API_PREFIX


if (getAbortController) { if (getAbortController) {
const abortController = new AbortController() const abortController = new AbortController()
options.signal = abortController.signal options.signal = abortController.signal
} }


const fetchPathname = `${base}${url.startsWith('/') ? url : `/${url}`}`
const fetchPathname = base + (url.startsWith('/') ? url : `/${url}`)


if (deleteContentType) if (deleteContentType)
(headers as any).delete('Content-Type') (headers as any).delete('Content-Type')
}, },
...(bodyStringify ? { json: body } : { body: body as BodyInit }), ...(bodyStringify ? { json: body } : { body: body as BodyInit }),
searchParams: params, searchParams: params,
fetch(resource: RequestInfo | URL, options?: RequestInit) {
if (resource instanceof Request && options) {
const mergedHeaders = new Headers(options.headers || {})
resource.headers.forEach((value, key) => {
mergedHeaders.append(key, value)
})
options.headers = mergedHeaders
}
return globalThis.fetch(resource, options)
},
}) })


if (needAllResponseContent) if (needAllResponseContent)

Loading…
取消
儲存