@detiq/crawler 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +8 -0
- package/package.json +1 -1
- package/src/crawler.ts +6 -3
package/Dockerfile
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
FROM mcr.microsoft.com/playwright:v1.55.0-jammy AS runner
|
|
6
6
|
WORKDIR /app
|
|
7
7
|
ENV NODE_ENV=production
|
|
8
|
+
# Install browsers to a fixed path — base image ships browsers here and
|
|
9
|
+
# we override after npm ci to match the exact installed playwright revision.
|
|
10
|
+
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
|
8
11
|
|
|
9
12
|
# Install Node.js 20 (Playwright base image ships with 18)
|
|
10
13
|
RUN apt-get update && apt-get install -y curl && \
|
|
@@ -21,6 +24,11 @@ COPY packages/agents/package.json packages/agents/
|
|
|
21
24
|
COPY packages/crawler/package.json packages/crawler/
|
|
22
25
|
RUN npm ci
|
|
23
26
|
|
|
27
|
+
# Re-install chromium after npm ci so the browser revision matches the
|
|
28
|
+
# exact playwright version resolved by the lockfile (not the base image's
|
|
29
|
+
# bundled version, which may differ if the lockfile was updated).
|
|
30
|
+
RUN npx playwright install chromium
|
|
31
|
+
|
|
24
32
|
# Source
|
|
25
33
|
COPY tsconfig.base.json ./
|
|
26
34
|
COPY packages/core packages/core
|
package/package.json
CHANGED
package/src/crawler.ts
CHANGED
|
@@ -978,11 +978,14 @@ export async function crawlProject(opts: {
|
|
|
978
978
|
// Non-fatal — crawl proceeds without API endpoint capture
|
|
979
979
|
}
|
|
980
980
|
// Final fallback: if rawPage is still null, use the Stagehand page (events may not work)
|
|
981
|
-
if (!rawPage)
|
|
981
|
+
if (!rawPage) {
|
|
982
|
+
rawPage = page;
|
|
983
|
+
logger.warn('[crawler] rawPage fell back to Stagehand proxy — CDP connectOverCDP failed; route() calls will be skipped');
|
|
984
|
+
}
|
|
982
985
|
|
|
983
986
|
// ── HTTP Basic Auth: inject Authorization header for same-origin requests ───
|
|
984
987
|
// Must use rawPage (real Playwright page) — Stagehand V3Page proxy does not implement route().
|
|
985
|
-
if (opts.httpBasicUsername && opts.httpBasicPassword) {
|
|
988
|
+
if (opts.httpBasicUsername && opts.httpBasicPassword && typeof rawPage?.route === 'function') {
|
|
986
989
|
const encoded = Buffer.from(`${opts.httpBasicUsername}:${opts.httpBasicPassword}`).toString('base64');
|
|
987
990
|
const appOrigin = new URL(opts.appUrl).origin;
|
|
988
991
|
await rawPage.route('**/*', (route: any) => {
|
|
@@ -1002,7 +1005,7 @@ export async function crawlProject(opts: {
|
|
|
1002
1005
|
// the crawler during long crawl sessions. The API verifies the secret before
|
|
1003
1006
|
// skipping the limiter.
|
|
1004
1007
|
const crawlerSecret = process.env.CRAWLER_INTERNAL_SECRET;
|
|
1005
|
-
if (crawlerSecret) {
|
|
1008
|
+
if (crawlerSecret && typeof rawPage?.route === 'function') {
|
|
1006
1009
|
const loginPattern = `${new URL(opts.appUrl).origin}**/auth/login*`;
|
|
1007
1010
|
await rawPage.route(loginPattern, (route: any) => {
|
|
1008
1011
|
route.continue({
|