diff --git a/packages/backend-core/src/db/couch/DatabaseImpl.ts b/packages/backend-core/src/db/couch/DatabaseImpl.ts index e10d0e58c6..b3fce7aa29 100644 --- a/packages/backend-core/src/db/couch/DatabaseImpl.ts +++ b/packages/backend-core/src/db/couch/DatabaseImpl.ts @@ -21,6 +21,7 @@ import { WriteStream, ReadStream } from "fs" import { newid } from "../../docIds/newid" import { SQLITE_DESIGN_DOC_ID } from "../../constants" import { DDInstrumentedDatabase } from "../instrumentation" +import { checkSlashesInUrl } from "../../helpers" const DATABASE_NOT_FOUND = "Database does not exist." @@ -252,17 +253,18 @@ export class DatabaseImpl implements Database { async _sqlQuery( url: string, method: "POST" | "GET", - body?: any + body?: Record ): Promise { + url = checkSlashesInUrl(`${this.couchInfo.sqlUrl}/${url}`) const args: { url: string; method: string; cookie: string; body?: any } = { - url: `${this.couchInfo.sqlUrl}/${url}`, + url, method, cookie: this.couchInfo.cookie, } if (body) { args.body = body } - const response = await directCouchUrlCall(body) + const response = await directCouchUrlCall(args) if (response.status > 300) { throw new Error(await response.text()) } diff --git a/packages/backend-core/src/db/couch/utils.ts b/packages/backend-core/src/db/couch/utils.ts index 005b02a896..270d953320 100644 --- a/packages/backend-core/src/db/couch/utils.ts +++ b/packages/backend-core/src/db/couch/utils.ts @@ -21,7 +21,7 @@ export async function directCouchUrlCall({ url: string cookie: string method: string - body?: any + body?: Record }) { const params: any = { method: method,