Enable global_fetch_strictly_public to fix WebDAV 522 (Worker deploy)

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]>
This commit is contained in:
Yu Lei
2026-06-15 15:03:36 +08:00
co-authored by Claude Opus 4.8
parent 9fb3cf723a
commit 1f68c6caa3
2 changed files with 4 additions and 0 deletions
+1
View File
@@ -23,6 +23,7 @@ const name = env.WORKER_NAME || 'cloudflare-imgbed';
let toml = `name = "${name}"
main = "index.js"
compatibility_date = "2024-08-21"
compatibility_flags = ["global_fetch_strictly_public"]
[assets]
directory = "../../frontend-dist"
+3
View File
@@ -13,6 +13,9 @@
name = "cloudflare-imgbed"
main = "index.js"
compatibility_date = "2024-08-21"
# 让 Worker 对自身 zone 的 fetch() 走公网前门(否则同域自调用绕过 Worker
# 直连 origin,没有 origin 时会秒回 522)。修复 WebDAV 列目录/上传/下载/删除。
compatibility_flags = ["global_fetch_strictly_public"]
# 静态资源(前端文件)
[assets]