Skip to content

Commit cd8a925

Browse files
Merge pull request #37 from threepointone/cloudflare-compat
Fix usage with cloudflare workers
2 parents 339e955 + b9da036 commit cd8a925

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ export class RealtimeAPI extends RealtimeEventHandler {
6363
if (this.isConnected()) {
6464
throw new Error(`Already connected`);
6565
}
66-
if (globalThis.document) {
66+
if (globalThis.WebSocket) {
6767
/**
6868
* Web browser
6969
*/
70-
if (this.apiKey) {
70+
if (globalThis.document && this.apiKey) {
7171
console.warn(
7272
'Warning: Connecting using API key in the browser, this is not recommended',
7373
);

0 commit comments

Comments
 (0)