SvelteKit and Cloudflare Compatibility Date after `2024-04-01`
Today, I needed to increase my compatibility_date for my Svelte project.
I noticed, that when I ran the project locally with npx wrangler dev, that no POST requests worked any longer.
There was a 405 Method Not Allowed HTTP error.
The same was true when I opened the branch preview deployment.
tl;dr: I added the assets_navigation_has_no_effect compatibility flag.
Now it works.
"$schema" = "./node_modules/wrangler/config-schema.json"
# …
compatibility_date = "2026-03-17"
compatibility_flags = ["nodejs_compat", "global_fetch_strictly_public", "assets_navigation_has_no_effect"]
# …
The problem is that Cloudflare changed how they invoke the worker with a compatibility date after 2024-04-01.
Before, the worker was invoked for every request.
After, the worker is not invoked if the request is a browser page navigation request.
A fetch('/somepage') would invoke the worker, a navigation with <a href="/somepage"> wouldn’t.
I don’t quite get the logic, to be honest. Especially, why they stop passing POST requests to the worker in this mode. Now it is, what it is.
The compatibility flag assets_navigation_has_no_effect tells the Cloudflare Worker environment that the worker must be invoked everytime.
In my case, I handle the caching on the CDN level anyway.
So I don’t worry too much about the worker being invoked too often.