Skip to content

Commit b8c4e19

Browse files
authored
Fix bad WebSocket URL in CrawlWatcher (#1053)
* fix: bad websocket url in crawl watcher Fixed CrawlWatcher creating WebSocket using standard http url from base app. * Use regex to improve url replacement
1 parent 6b9e65c commit b8c4e19

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/js-sdk/firecrawl/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,9 @@ export class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
12981298
constructor(id: string, app: FirecrawlApp) {
12991299
super();
13001300
this.id = id;
1301-
this.ws = new WebSocket(`${app.apiUrl}/v1/crawl/${id}`, app.apiKey);
1301+
// replace `http` with `ws` (`http://` -> `ws://` and `https://` -> `wss://`)
1302+
const wsUrl = app.apiUrl.replace(/^http/, "ws");
1303+
this.ws = new WebSocket(`${wsUrl}/v1/crawl/${id}`, app.apiKey);
13021304
this.status = "scraping";
13031305
this.data = [];
13041306

0 commit comments

Comments
 (0)