diff --git a/backend/functions/src/cloud-functions/searcher.ts b/backend/functions/src/cloud-functions/searcher.ts index 0af9ef3..c2da3ad 100644 --- a/backend/functions/src/cloud-functions/searcher.ts +++ b/backend/functions/src/cloud-functions/searcher.ts @@ -86,11 +86,12 @@ export class SearcherHost extends RPCHost { count: number, crawlerOptions: CrawlerOptions, braveSearchExplicitOperators: BraveSearchExplicitOperatorsDto, + @Param('q') q?: string, ) { const uid = await auth.solveUID(); let chargeAmount = 0; const noSlashPath = ctx.req.url.slice(1); - if (!noSlashPath) { + if (!noSlashPath && !q) { const latestUser = uid ? await auth.assertUser() : undefined; if (!ctx.req.accepts('text/plain') && (ctx.req.accepts('text/json') || ctx.req.accepts('application/json'))) { @@ -151,7 +152,7 @@ export class SearcherHost extends RPCHost { delete crawlerOptions.html; const crawlOpts = this.crawler.configure(crawlerOptions); - const searchQuery = braveSearchExplicitOperators.addTo(ctx.req.path.slice(1)); + const searchQuery = braveSearchExplicitOperators.addTo(q || ctx.req.path.slice(1)); const r = await this.cachedWebSearch({ q: searchQuery, count: Math.floor(count + 2)