Skip to content

Commit 79d4211

Browse files
Handle typo in powersync_url env variable (#333)
1 parent 0898a58 commit 79d4211

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.changeset/fuzzy-bears-nail.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@powersync/common': patch
3+
'@powersync/web': patch
4+
---
5+
6+
Handle additional forward slash in the POWERSYNC_URL environment variable

packages/common/src/client/sync/stream/AbstractRemote.ts

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { version as POWERSYNC_JS_VERSION } from '../../../../package.json';
1414

1515
export type BSONImplementation = typeof BSON;
1616

17+
const POWERSYNC_TRAILING_SLASH_MATCH = /\/+$/;
1718
export type RemoteConnector = {
1819
fetchCredentials: () => Promise<PowerSyncCredentials | null>;
1920
};
@@ -108,6 +109,11 @@ export abstract class AbstractRemote {
108109
return this.credentials!;
109110
}
110111
this.credentials = await this.connector.fetchCredentials();
112+
if (this.credentials?.endpoint.match(POWERSYNC_TRAILING_SLASH_MATCH)) {
113+
throw new Error(
114+
`A trailing forward slash "/" was found in the fetchCredentials endpoint: "${this.credentials.endpoint}". Remove the trailing forward slash "/" to fix this error.`
115+
);
116+
}
111117
return this.credentials;
112118
}
113119

0 commit comments

Comments
 (0)