diff --git a/.changeset/famous-suns-end.md b/.changeset/famous-suns-end.md new file mode 100644 index 0000000..237c498 --- /dev/null +++ b/.changeset/famous-suns-end.md @@ -0,0 +1,5 @@ +--- +'fireworkers': patch +--- + +fix: wrong firestore endpoint URL constructor diff --git a/src/utils.ts b/src/utils.ts index b7f269f..2fac4c6 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -11,11 +11,9 @@ export const get_firestore_endpoint = ( paths: string[] = [], suffix = '' ): URL => { - const path = paths.join('/') + suffix; - const endpoint = new URL( - path, - `${FIRESTORE_ENDPOINT}/v1/projects/${project_id}/databases/(default)/documents` - ); + const allPaths = ['v1', 'projects', project_id, 'databases', '(default)', 'documents', ...paths]; + const path = allPaths.join('/') + suffix; + const endpoint = new URL(path, FIRESTORE_ENDPOINT); return endpoint; };