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.
This commit is contained in:
Julien Calixte
2026-06-02 21:23:47 +02:00
parent 7c3d34d02e
commit 901f7f4c02

View File

@@ -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'