Workers routes in *.pages.dev domains

I’m requesting the ability to define Workers routes that cover *.pages.dev domains much in the same way they can define route patterns for other zones within the account, e.g.

{ pattern = "*project-name.pages.dev/api/*", zone_name = "project-name.pages.dev" }

Say I have a site on Pages that relies on a /api/* workers route (actually, “Pages Function”), and is deployed to a custom domain (say example.com). I want that same worker to also serve a custom domain like api.example.com.

I’m sure the answer to this is “not currently possible” because variations of this question have been asked several times before, so this is more of a feature request, pointing out that those existing proposed workarounds are not satisfactory:

  • Using Pages Functions to handle *.pages.dev/api/* (and example.com/api/*) routes, but that “Pages Function” cannot also serve the custom domain route api.example.com/* (it would be a different/duplicated worker script, disparities in deployments, more to maintain, worker global variables not shared)
  • Mapping a Pages preview branch to a custom domain and then using a Workers route on that custom domain. This does not scale for an arbitrary number previews, and the fact remains that *.pages.dev/api/* will not be served by the worker so the pages.dev domain would still be non-functional without the duplicated Pages Function.