Skip to content

Commit 9cdaae4

Browse files
authored
feat(api): allow index with enhanced mode (firecrawl#3158)
1 parent 67c9dbd commit 9cdaae4

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

apps/api/src/lib/native-logging.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Logger } from "winston";
33
const NATIVE_LOGS_SEPARATOR = "\n__native_logs__:";
44

55
/** Matches the NativeLogEntry struct from Rust (@mendable/firecrawl-rs). */
6-
export interface NativeLogEntry {
6+
interface NativeLogEntry {
77
level: string;
88
target: string;
99
message: string;

apps/api/src/scraper/scrapeURL/engines/index.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ const engineOptions: {
213213
location: true,
214214
skipTlsVerification: true,
215215
useFastMode: true,
216-
stealthProxy: false,
216+
stealthProxy: true,
217217
branding: false,
218218
disableAdblock: true,
219219
},
@@ -270,7 +270,7 @@ const engineOptions: {
270270
mobile: true,
271271
skipTlsVerification: true,
272272
useFastMode: true,
273-
stealthProxy: false,
273+
stealthProxy: true,
274274
branding: false,
275275
disableAdblock: false,
276276
},
@@ -467,8 +467,7 @@ export function shouldUseIndex(meta: Meta) {
467467
meta.options.maxAge !== 0 &&
468468
(meta.options.headers === undefined ||
469469
Object.keys(meta.options.headers).length === 0) &&
470-
(meta.options.actions === undefined || meta.options.actions.length === 0) &&
471-
meta.options.proxy !== "stealth"
470+
(meta.options.actions === undefined || meta.options.actions.length === 0)
472471
);
473472
}
474473

@@ -561,7 +560,11 @@ export async function buildFallbackList(meta: Meta): Promise<
561560
}
562561
}
563562

564-
if (selectedEngines.some(x => engineOptions[x.engine].quality > 0)) {
563+
if (
564+
selectedEngines.some(
565+
x => engineOptions[x.engine].quality > 0 && !x.engine.startsWith("index"),
566+
)
567+
) {
565568
selectedEngines = selectedEngines.filter(
566569
x => engineOptions[x.engine].quality > 0,
567570
);
@@ -628,7 +631,10 @@ export async function scrapeURLWithEngine(
628631
});
629632

630633
const featureFlags = new Set(meta.featureFlags);
631-
if (engineOptions[engine].features.stealthProxy) {
634+
if (
635+
engineOptions[engine].features.stealthProxy &&
636+
!engine.startsWith("index") // don't force stealth proxy for index
637+
) {
632638
featureFlags.add("stealthProxy");
633639
}
634640

apps/api/src/scraper/scrapeURL/engines/index/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export async function sendDocumentToIndex(meta: Meta, document: Document) {
151151
location_languages: meta.options.location?.languages ?? null,
152152
status: document.metadata.statusCode,
153153
is_precrawl: meta.internalOptions.isPreCrawl === true,
154+
is_stealth: meta.featureFlags.has("stealthProxy"),
154155
wait_time_ms: meta.options.waitFor > 0 ? meta.options.waitFor : null,
155156
...urlSplitsHash.slice(0, 10).reduce(
156157
(a, x, i) => ({
@@ -259,7 +260,7 @@ export async function scrapeURLWithIndex(
259260
const checkpoint1 = Date.now();
260261

261262
const { data, error } = await index_supabase_service.rpc(
262-
"index_get_recent_3",
263+
"index_get_recent_4",
263264
{
264265
p_url_hash: urlHash,
265266
p_max_age_ms: maxAge,
@@ -275,6 +276,7 @@ export async function scrapeURLWithIndex(
275276
? meta.options.location?.languages
276277
: null,
277278
p_wait_time_ms: meta.options.waitFor,
279+
p_is_stealth: meta.featureFlags.has("stealthProxy"),
278280
p_min_age_ms: meta.options.minAge ?? null,
279281
},
280282
);

0 commit comments

Comments
 (0)