-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
@sveltejs/adapter-cloudflare@7.2.7 introduced _redirects parsing for _routes.json exclude rules (from #9138). However, the parse_redirects() function in utils.js does not skip comment lines (lines starting with #).
This causes comments like # Redirects for Cloudflare Pages to be parsed as redirect rules — the first word # gets added to the _routes.json exclude array. Cloudflare Pages then rejects the deployment with:
Error 8000057: Rules must start with '/' in `_routes.json`
Reproduction
-
Create a
_redirectsfile in project root with any comment:# This is a comment -
Build with
adapter-cloudflare@7.2.7:SVELTE_ADAPTER=cloudflare npm run build
-
Inspect
.svelte-kit/cloudflare/_routes.json— it contains"#"in the exclude array:{ "version": 1, "include": ["/*"], "exclude": [ "/_app/version.json", "/_app/immutable/*", "/icons/icon-generator.html", "/manifest.json", "#" ] } -
Deploy to Cloudflare Pages — fails with error 8000057.
Workaround
Remove all comments from the _redirects file (or delete it if empty).
Severity
This is a deployment blocker — any project with comments in _redirects cannot deploy to Cloudflare Pages with adapter-cloudflare 7.2.7.
System Info
adapter-cloudflare: 7.2.7
@sveltejs/kit: 2.52.0
OS: macOS Darwin 25.3.0
Node: 22.x