Cloudflare Worker routes with regexp?

Is there any chance that Cloudflare Worker routes will support regular expressions? This would be really useful as we could gradually move to Workers, and keep everything that cannot be static served (backend, forms) the way it is right now.

We’re using wrangler to deploy now.

I guess it could also possible to adapt the deployed JS to make this feasible somehow? But even then, this would require a lot more thinking and code than simply having routes with regexp.

1 Like

I also would like this, and for page rules as well.

I’m not confident it’s possible now, but you can just match the regexp in your Worker script and return await fetch(request) (simulate pass-through) when the request path doesn’t match. Then you can add a catch-all route and let Worker handle the actual routing pattern. Number of requests may be a concern greater than before, however.

This topic was automatically closed after 30 days. New replies are no longer allowed.