From 901f7f4c02d8c4c8cf512d0d4149c00b4b7717d5 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Tue, 2 Jun 2026 21:23:47 +0200 Subject: [PATCH] fix(sync): send credentials on cross-origin couchdb requests PouchDB 8+ ignores the legacy ajax config, so withCredentials had no effect and the AuthSession cookie was stripped from cross-origin sync requests. Switch to a fetch wrapper that sets credentials: 'include' so replication authenticates and pushes local docs to the remote. --- src/services/CouchService.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/CouchService.ts b/src/services/CouchService.ts index 3e0183d..1848900 100644 --- a/src/services/CouchService.ts +++ b/src/services/CouchService.ts @@ -11,11 +11,11 @@ PouchDb.plugin(PouchDbAuthentication) const emit = debounce((ev: typeof SYNC, arr?: string[]) => bus.emit(ev, arr), 150) -const remoteConfig = { +const remoteConfig: PouchDB.Configuration.RemoteDatabaseConfiguration = { skip_setup: true, - ajax: { - cache: true, - withCredentials: true + fetch: (url, opts) => { + const init: RequestInit = { ...(opts ?? {}), credentials: 'include' } + return PouchDb.fetch(url as RequestInfo, init) } } const LOCALE_DB = 'VAQUANT_LOCALE_DB'