On a Cloudflare Worker, fetch() to the Worker's own zone bypasses the
public edge and routes directly to origin, skipping the Worker itself.
This deployment has no separate origin, so every WebDAV self-call
(/api/manage/list, /file, /upload, /api/manage/delete) instantly returns
HTTP 522. The global_fetch_strictly_public compatibility flag routes
same-zone subrequests through Cloudflare's front door so they re-enter
the Worker normally.
Set the flag in both the committed wrangler.toml (manual deploy) and the
generate-toml.js template (GitHub Actions regenerates the toml on CI).
This is an alternative to the in-process dispatch fix on
fix/webdav-522-inprocess-dispatch; pick one.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
The loop in findFunctionFile started from parts.length - 1, which
skipped the directory-level [[path]].js match when the request path
had exactly one segment (e.g. /dav/, /file/). Changed to start from
parts.length so these root paths correctly resolve to their handlers.
Fixes /dav/ returning 404 and /file/ similarly affected.
Cloudflare Workers and Pages already provide the Fetch/Web APIs needed for WebDAV verbs, so the storage integration uses a small local helper instead of adding a Node-oriented WebDAV client. The channel now participates in upload, read, delete, move, rename, channel listing, and runtime config, with chunked uploads explicitly guarded because WebDAV has no portable server-side compose primitive.
Constraint: Preserve Pages Functions and generated Worker deployment paths
Constraint: No new npm dependency for WebDAV client behavior
Rejected: Add a WebDAV npm client | likely Node API/compatibility and package-lock churn
Rejected: Treat WebDAV as External URL only | not a complete storage channel lifecycle
Confidence: high
Scope-risk: moderate
Directive: WebDAV here is third-party storage; keep it distinct from the built-in /dav server settings
Tested: npm test; node worker/generate-routes.js; npx wrangler deploy --dry-run --config worker/wrangler.toml; git diff --cached --check
Not-tested: Live third-party WebDAV provider credentials; Digest-only WebDAV authentication