Use case or problem
The request() and requestUrl() APIs are used to make requests that bypass CORS restrictions.
I’m using those APIs in order to fetch data from HTTP endpoints that don’t set the CORS headers e.g. different LLM providers HTTP endpoints. Often these endpoints stream the content back in chunks, that is extremely useful to visualize before the entire request is completed.
Proposed solution
I propose to return a readable stream similarly to the native javascript fetch() function. In this proposal the request()
returned promise resolves after the headers are available, and the body is exposed to the caller as a stream rather than waiting for the full body to be received. If the new interface results not backward compatible a requestUrlStream()
could be introduced.
Current workaround
Unfortunately currently there’s no workaround, since mobile Obsidian plugin’s only way to make CORS http requests is using the request()
and requestUrl()
APIs given the absence of the Nodejs server. It’s not currently possible to stream a CORS http fetch result made with request()
and requestUrl()
.