diff --git a/app/api/webdav/[...path]/route.ts b/app/api/webdav/[...path]/route.ts index f64a9ef13..b0083fd69 100644 --- a/app/api/webdav/[...path]/route.ts +++ b/app/api/webdav/[...path]/route.ts @@ -42,7 +42,7 @@ async function handle( } const endpointPath = params.path.join("/"); - const targetPath = `${endpoint}/${endpointPath}`; + const targetPath = `${endpoint}${endpointPath}`; // only allow MKCOL, GET, PUT if (req.method !== "MKCOL" && req.method !== "GET" && req.method !== "PUT") { @@ -96,7 +96,7 @@ async function handle( ); } - const targetUrl = `${endpoint}/${endpointPath}`; + const targetUrl = targetPath; const method = req.method; const shouldNotHaveBody = ["get", "head"].includes( @@ -114,13 +114,22 @@ async function handle( duplex: "half", }; - const fetchResult = await fetch(targetUrl, fetchOptions); - console.log("[Any Proxy]", targetUrl, { - status: fetchResult.status, - statusText: fetchResult.statusText, + method: req.method, + params: req.body, }); + let fetchResult; + + try { + fetchResult = await fetch(targetUrl, fetchOptions); + } finally { + console.log("[Any Proxy]", targetUrl, { + status: fetchResult?.status, + statusText: fetchResult?.statusText, + }); + } + return fetchResult; } diff --git a/app/store/sync.ts b/app/store/sync.ts index 674ff6744..8ee6c1819 100644 --- a/app/store/sync.ts +++ b/app/store/sync.ts @@ -104,6 +104,7 @@ export const useSyncStore = createPersistStore( setLocalAppState(localState); } catch (e) { console.log("[Sync] failed to get remote state", e); + throw e; } await client.set(config.username, JSON.stringify(localState)); diff --git a/app/utils/cloud/webdav.ts b/app/utils/cloud/webdav.ts index e01c193fe..71d452b4a 100644 --- a/app/utils/cloud/webdav.ts +++ b/app/utils/cloud/webdav.ts @@ -76,7 +76,7 @@ export function createWebDavClient(store: SyncStore) { let url; if (proxyUrl.length > 0 || proxyUrl === "/") { - let u = new URL(proxyUrl + "/api/webdav/" + path); + let u = new URL(proxyUrl + "api/webdav/" + path); // add query params u.searchParams.append("endpoint", config.endpoint); url = u.toString();