fix nextcloud WebDAV csrf error (#1448)
This commit is contained in:
parent
6e0cfb7d0f
commit
9364ef585f
|
@ -274,11 +274,21 @@ const syncMan = (() => {
|
|||
if (name === 'dropbox' || name === 'google' || name === 'onedrive' || name === 'webdav') {
|
||||
const options = await syncMan.getDriveOptions(name);
|
||||
options.getAccessToken = () => tokenMan.getToken(name);
|
||||
options.fetch = name === 'webdav' ? fetchWebDAV.bind(options) : fetch;
|
||||
return dbToCloud.drive[name](options);
|
||||
}
|
||||
throw new Error(`unknown cloud name: ${name}`);
|
||||
}
|
||||
|
||||
/** @this {Object} DriveOptions */
|
||||
function fetchWebDAV(url, init = {}) {
|
||||
init.credentials = 'omit'; // circumventing nextcloud CSRF token error
|
||||
init.headers = Object.assign({}, init.headers, {
|
||||
Authorization: `Basic ${btoa(`${this.username || ''}:${this.password || ''}`)}`,
|
||||
});
|
||||
return fetch(url, init);
|
||||
}
|
||||
|
||||
function schedule(delay = SYNC_DELAY) {
|
||||
chrome.alarms.create('syncNow', {
|
||||
delayInMinutes: delay, // fractional values are supported
|
||||
|
|
Loading…
Reference in New Issue
Block a user