diff --git a/apps/js-sdk/firecrawl/src/index.ts b/apps/js-sdk/firecrawl/src/index.ts index 3deeb909bf..58f772112d 100644 --- a/apps/js-sdk/firecrawl/src/index.ts +++ b/apps/js-sdk/firecrawl/src/index.ts @@ -1298,7 +1298,9 @@ export class CrawlWatcher extends TypedEventTarget { constructor(id: string, app: FirecrawlApp) { super(); this.id = id; - this.ws = new WebSocket(`${app.apiUrl}/v1/crawl/${id}`, app.apiKey); + // replace `http` with `ws` (`http://` -> `ws://` and `https://` -> `wss://`) + const wsUrl = app.apiUrl.replace(/^http/, "ws"); + this.ws = new WebSocket(`${wsUrl}/v1/crawl/${id}`, app.apiKey); this.status = "scraping"; this.data = [];