isomorphic-git/isomorphic-git

Support custom Fetch options in http/web

已关闭

#1,246 创建于 2020年10月14日

 (3 条评论) (1 个反应) (0 位负责人)JavaScript (351 个派生)batch import
good first issue

仓库指标

星标
 (7,054 个星标)
PR 合并指标
 (平均合并 13天 13小时) (30 天内合并 7 个 PR)

描述

I suppose this also applies to http/node but I specifically ran into this limitation with http/web. It's possible to customize request headers in functions like clone. However, it is not possible to supply custom fetch options since the current http client has no such argument.

One use case would be using an internal corsProxy that has its own non-token auth such as session/cookie or Basic Auth. To authenticate against the API, fetch would need to have credentials: 'include' option. Without it, the browser wouldn't forward the HTTP-only session cookie or the Basic Auth credentials. (The headers param described here only works for token-based auth.)

As a workaround, I "forked" http/web/index.js into our project. However, this seems inefficient since credentials: 'include' is the only substantive change I had to make. Furthermore, I had to copy-paste a few util functions which, if this workaround is encouraged, should ideally be exported from the lib in src/index.js.

Could we make the built-in HTTP client more robust? Here are the fetch options once again for reference.

贡献者指南