Support custom Fetch options in http/web
#1.246 geöffnet am 14.10.2020
Repository-Metriken
- Stars
- (7.054 Sterne)
- PR-Merge-Metriken
- (Durchschn. Merge 13T 13h) (7 gemergte PRs in 30 T)
Beschreibung
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.