diff --git a/src/core/cache-storage.ts b/src/core/cache-storage.ts index 2be98edeb..1ef17c1f6 100644 --- a/src/core/cache-storage.ts +++ b/src/core/cache-storage.ts @@ -31,6 +31,7 @@ export interface ResourceOptions { useCORS: boolean; allowTaint: boolean; proxy?: string; + withCredentials?: boolean; } export class Cache { @@ -145,6 +146,9 @@ export class Cache { reject(`Failed to proxy resource ${key} with status code ${xhr.status}`); } }; + if (this._options.withCredentials) { + xhr.withCredentials = true; + } xhr.onerror = reject; const queryString = proxy.indexOf('?') > -1 ? '&' : '?'; diff --git a/src/index.ts b/src/index.ts index 348b050fb..3fe23dd5a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -52,6 +52,7 @@ const renderElement = async (element: HTMLElement, opts: Partial): Prom const contextOptions = { logging: opts.logging ?? true, cache: opts.cache, + withCredentials: opts.withCredentials, ...resourceOptions };