Skip to content

Official Crawl4AI Cloud: a hosted web scraping, extraction, and search API for AI agents. Free API key, 1,000 credits a month, no card. Fully open source: this repo is the Apache-2.0 crawler that powers it, and you can self-host it.

fix(docker): playground config type + monitor websocket auth dep

Pitchfork-and-Torch1a28980713f1
diff --git a/deploy/docker/server.py b/deploy/docker/server.py
index 07eb5d7d..410b8be3 100644
--- a/deploy/docker/server.py
+++ b/deploy/docker/server.py
@@ -482,8 +482,12 @@ def _config_from_json(data: dict) -> dict:
app.include_router(init_job_router(redis, config, token_dep))
# ── monitor router ──────────────────────────────────────────
+# Do not attach token_dep at router level: it is HTTP Request-only and breaks
+# the WebSocket upgrade on /monitor/ws (TypeError: _principal() missing 'request').
+# AuthGateMiddleware already authenticates HTTP + WS; destructive monitor
+# actions keep their own Depends(require_admin).
from monitor_routes import router as monitor_router
-app.include_router(monitor_router, dependencies=[Depends(token_dep)])
+app.include_router(monitor_router)
logger = logging.getLogger(__name__)
diff --git a/deploy/docker/static/playground/index.html b/deploy/docker/static/playground/index.html
index 41b04e86..e88c281a 100644
--- a/deploy/docker/static/playground/index.html
+++ b/deploy/docker/static/playground/index.html
@@ -563,10 +563,13 @@
const code = cm.getValue().trim();
if (!code) return {};
+ // Server requires `type` alongside `code` (CrawlerRunConfig | BrowserConfig).
+ // The UI already tracks this in #cfg-type; omitting it always 400s Advanced Config.
+ const cfgType = document.getElementById('cfg-type').value;
const res = await authFetch('/config/dump', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ code }),
+ body: JSON.stringify({ type: cfgType, code }),
});
const statusEl = document.getElementById('cfg-status');
@@ -652,9 +655,12 @@
// Detect if stream is requested inside payload
function shouldUseStream(payload) {
const toBool = (v) => v === true || (typeof v === 'string' && v.toLowerCase() === 'true');
- const fromCrawler = payload && payload.crawler_config && payload.crawler_config.params && payload.crawler_config.params.stream;
+ // Successful /config/dump returns { type, params: { stream, ... } }
+ const fromCrawlerParams = payload && payload.crawler_config && payload.crawler_config.params && payload.crawler_config.params.stream;
+ // Fallback / minimal shapes may set stream at the crawler_config top level
+ const fromCrawlerTop = payload && payload.crawler_config && payload.crawler_config.stream;
const direct = payload && payload.stream;
- return toBool(fromCrawler) || toBool(direct);
+ return toBool(fromCrawlerParams) || toBool(fromCrawlerTop) || toBool(direct);
}
// Main run function
@@ -676,8 +682,8 @@
const streamFlag = /stream\s*=\s*True/i.test(codeText);
const isCrawlEndpoint = document.getElementById('endpoint').value === 'crawl';
if (isCrawlEndpoint && streamFlag) {
- // Fallback: proceed with minimal config only for stream
- advConfig = { crawler_config: { stream: true } };
+ // Fallback: minimal dump-shaped config so shouldUseStream + server load agree
+ advConfig = { crawler_config: { type: 'CrawlerRunConfig', params: { stream: true } } };
} else {
updateStatus('error');
document.querySelector('#response-content code').textContent =