Skip to content

Commit

Permalink
Fix bad WebSocket URL in CrawlWatcher (#1053)
Browse files Browse the repository at this point in the history
* fix: bad websocket url in crawl watcher

Fixed CrawlWatcher creating WebSocket using standard http url from base app.

* Use regex to improve url replacement
  • Loading branch information
ProfHercules authored Jan 28, 2025
1 parent 6b9e65c commit b8c4e19
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/js-sdk/firecrawl/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,9 @@ export class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
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 = [];

Expand Down

0 comments on commit b8c4e19

Please sign in to comment.