diff --git a/packages/web/src.ts/browser-geturl.ts b/packages/web/src.ts/browser-geturl.ts index 7770da79a..88d5424ab 100644 --- a/packages/web/src.ts/browser-geturl.ts +++ b/packages/web/src.ts/browser-geturl.ts @@ -23,6 +23,15 @@ export async function getUrl(href: string, options?: Options): Promise(opts.mode); } + if (opts.cache) { request.cache = (opts.cache); } + if (opts.credentials) { request.credentials = (opts.credentials); } + if (opts.redirect) { request.redirect = (opts.redirect); } + if (opts.referrer) { request.referrer = opts.referrer; } + } + const response = await fetch(href, request); const body = await response.arrayBuffer(); diff --git a/packages/web/src.ts/index.ts b/packages/web/src.ts/index.ts index c46cf9203..5cf3fd8ba 100644 --- a/packages/web/src.ts/index.ts +++ b/packages/web/src.ts/index.ts @@ -50,6 +50,7 @@ export type ConnectionInfo = { throttleCallback?: (attempt: number, url: string) => Promise, skipFetchSetup?: boolean; + fetchOptions?: Record; errorPassThrough?: boolean; timeout?: number, @@ -158,7 +159,12 @@ export function _fetchData(connection: string | ConnectionInfo, if (connection.skipFetchSetup != null) { options.skipFetchSetup = !!connection.skipFetchSetup; } + + if (connection.fetchOptions != null) { + options.fetchOptions = shallowCopy(connection.fetchOptions); + } } + const reData = new RegExp("^data:([a-z0-9-]+/[a-z0-9-]+);base64,(.*)$", "i"); const dataMatch = ((url) ? url.match(reData): null); if (dataMatch) { diff --git a/packages/web/src.ts/types.ts b/packages/web/src.ts/types.ts index 3c80dc8ee..f43cf75ae 100644 --- a/packages/web/src.ts/types.ts +++ b/packages/web/src.ts/types.ts @@ -13,5 +13,6 @@ export type Options = { body?: Uint8Array; headers?: { [ key: string] : string }; skipFetchSetup?: boolean; + fetchOptions?: Record; };