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
This commit is contained in:
Hercules Smith 2025-01-28 09:40:30 +02:00 committed by GitHub
parent 6b9e65c4f6
commit b8c4e198d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1298,7 +1298,9 @@ export class CrawlWatcher extends TypedEventTarget<CrawlWatcherEvents> {
constructor(id: string, app: FirecrawlApp) { constructor(id: string, app: FirecrawlApp) {
super(); super();
this.id = id; 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.status = "scraping";
this.data = []; this.data = [];