Skip to content

Commit 57c66f4

Browse files
committed
🐛 修复 WebDAV 同步请求携带浏览器 cookies 导致认证冲突的问题 (#1297)
1 parent b6b3a00 commit 57c66f4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/filesystem/webdav/webdav.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import type { AuthType, FileStat, WebDAVClient } from "webdav";
2-
import { createClient } from "webdav";
2+
import { createClient, getPatcher } from "webdav";
33
import type FileSystem from "../filesystem";
44
import type { FileInfo, FileCreateOptions, FileReader, FileWriter } from "../filesystem";
55
import { joinPath } from "../utils";
66
import { WebDAVFileReader, WebDAVFileWriter } from "./rw";
77
import { WarpTokenError } from "../error";
88

9+
// 禁止 WebDAV 请求携带浏览器 cookies,只通过账号密码认证 (#1297)
10+
getPatcher().patch("fetch", (...args: unknown[]) => {
11+
const options = (args[1] as RequestInit) || {};
12+
return fetch(args[0] as RequestInfo | URL, { ...options, credentials: "omit" });
13+
});
14+
915
export default class WebDAVFileSystem implements FileSystem {
1016
client: WebDAVClient;
1117

0 commit comments

Comments
 (0)