Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added field withCredentials to xhr #3128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/core/cache-storage.ts
Expand Up @@ -31,6 +31,7 @@ export interface ResourceOptions {
useCORS: boolean;
allowTaint: boolean;
proxy?: string;
withCredentials?: boolean;
}

export class Cache {
Expand Down Expand Up @@ -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 ? '&' : '?';
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Expand Up @@ -52,6 +52,7 @@ const renderElement = async (element: HTMLElement, opts: Partial<Options>): Prom
const contextOptions = {
logging: opts.logging ?? true,
cache: opts.cache,
withCredentials: opts.withCredentials,
...resourceOptions
};

Expand Down