Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(crawl,batch-scrape): return correct protocol on local deployments

Gergő Móricz45b498ddd183
diff --git a/apps/api/src/controllers/v1/batch-scrape.ts b/apps/api/src/controllers/v1/batch-scrape.ts
index 233e367d1..a43064e8b 100644
--- a/apps/api/src/controllers/v1/batch-scrape.ts
+++ b/apps/api/src/controllers/v1/batch-scrape.ts
@@ -211,7 +211,7 @@ export async function batchScrapeController(
await sender?.send(WebhookEvent.BATCH_SCRAPE_STARTED, { success: true });
}
- const protocol = process.env.ENV === "local" ? req.protocol : "https";
+ const protocol = req.protocol;
return res.status(200).json({
success: true,
diff --git a/apps/api/src/controllers/v1/crawl-status.ts b/apps/api/src/controllers/v1/crawl-status.ts
index 5a80cc665..42a0ebc2e 100644
--- a/apps/api/src/controllers/v1/crawl-status.ts
+++ b/apps/api/src/controllers/v1/crawl-status.ts
@@ -270,7 +270,7 @@ export async function crawlStatusController(
next:
(outputBulkA.total ?? 0) > start + iteratedOver ||
outputBulkA.status !== "completed"
- ? `${process.env.ENV === "local" ? req.protocol : "https"}://${req.get("host")}/v1/${isBatch ? "batch/scrape" : "crawl"}/${req.params.jobId}?skip=${start + iteratedOver}${req.query.limit ? `&limit=${req.query.limit}` : ""}`
+ ? `${req.protocol}://${req.get("host")}/v1/${isBatch ? "batch/scrape" : "crawl"}/${req.params.jobId}?skip=${start + iteratedOver}${req.query.limit ? `&limit=${req.query.limit}` : ""}`
: undefined,
};
diff --git a/apps/api/src/controllers/v1/crawl.ts b/apps/api/src/controllers/v1/crawl.ts
index 5b5fdfa7a..bdc3190e3 100644
--- a/apps/api/src/controllers/v1/crawl.ts
+++ b/apps/api/src/controllers/v1/crawl.ts
@@ -165,7 +165,7 @@ export async function crawlController(
crypto.randomUUID(),
);
- const protocol = process.env.ENV === "local" ? req.protocol : "https";
+ const protocol = req.protocol;
return res.status(200).json({
success: true,
diff --git a/apps/api/src/controllers/v2/batch-scrape.ts b/apps/api/src/controllers/v2/batch-scrape.ts
index 418de7b7a..4e3dafb4f 100644
--- a/apps/api/src/controllers/v2/batch-scrape.ts
+++ b/apps/api/src/controllers/v2/batch-scrape.ts
@@ -208,7 +208,7 @@ export async function batchScrapeController(
await sender?.send(WebhookEvent.BATCH_SCRAPE_STARTED, { success: true });
}
- const protocol = process.env.ENV === "local" ? req.protocol : "https";
+ const protocol = req.protocol;
return res.status(200).json({
success: true,
diff --git a/apps/api/src/controllers/v2/crawl-status.ts b/apps/api/src/controllers/v2/crawl-status.ts
index 8f4688993..c3b5e5505 100644
--- a/apps/api/src/controllers/v2/crawl-status.ts
+++ b/apps/api/src/controllers/v2/crawl-status.ts
@@ -282,7 +282,7 @@ export async function crawlStatusController(
next:
(outputBulkA.total ?? 0) > start + iteratedOver ||
outputBulkA.status !== "completed"
- ? `${process.env.ENV === "local" ? req.protocol : "https"}://${req.get("host")}/v1/${isBatch ? "batch/scrape" : "crawl"}/${req.params.jobId}?skip=${start + iteratedOver}${req.query.limit ? `&limit=${req.query.limit}` : ""}`
+ ? `${req.protocol}://${req.get("host")}/v1/${isBatch ? "batch/scrape" : "crawl"}/${req.params.jobId}?skip=${start + iteratedOver}${req.query.limit ? `&limit=${req.query.limit}` : ""}`
: undefined,
};
diff --git a/apps/api/src/controllers/v2/crawl.ts b/apps/api/src/controllers/v2/crawl.ts
index d588d3a00..1652a0aa7 100644
--- a/apps/api/src/controllers/v2/crawl.ts
+++ b/apps/api/src/controllers/v2/crawl.ts
@@ -232,7 +232,7 @@ export async function crawlController(
crypto.randomUUID(),
);
- const protocol = process.env.ENV === "local" ? req.protocol : "https";
+ const protocol = req.protocol;
return res.status(200).json({
success: true,