mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-09-01 00:07:06 +00:00
fix: strip trailing slash from couchDB_URI to avoid double-slash 401
When couchDB_URI ends with a trailing slash (e.g. https://host/), the database name concatenation produces a double-slash path (https://host//obsidiannotes), which causes CouchDB to reject requests with 401 "Name or password is incorrect". Strip trailing slashes from couchDB_URI / baseUri at the path concatenation sites in: - src/common/utils.ts (_requestToCouchDBFetch, _requestToCouchDB) - src/features/LocalDatabaseMainte/CmdLocalDatabaseMainte.ts The companion fix for the replication path is in the livesync-commonlib submodule. Ref: #859
This commit is contained in:
+2
-2
@@ -138,7 +138,7 @@ export const _requestToCouchDBFetch = async (
|
||||
authorization: authHeader,
|
||||
"content-type": "application/json",
|
||||
};
|
||||
const uri = `${baseUri}/${path}`;
|
||||
const uri = `${baseUri.replace(/\/+$/, "")}/${path}`;
|
||||
const requestParam = {
|
||||
url: uri,
|
||||
method: method || (body ? "PUT" : "GET"),
|
||||
@@ -162,7 +162,7 @@ export const _requestToCouchDB = async (
|
||||
const authHeaderGen = new AuthorizationHeaderGenerator();
|
||||
const authHeader = await authHeaderGen.getAuthorizationHeader(credentials);
|
||||
const transformedHeaders: Record<string, string> = { authorization: authHeader, origin: origin, ...customHeaders };
|
||||
const uri = `${baseUri}/${path}`;
|
||||
const uri = `${baseUri.replace(/\/+$/, "")}/${path}`;
|
||||
const requestParam: RequestUrlParam = {
|
||||
url: uri,
|
||||
method: method || (body ? "PUT" : "GET"),
|
||||
|
||||
Reference in New Issue
Block a user