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:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user