Can Worker Routes be used to host a separate backend on the same domain where the web app is hosted?

Say we have domain.com where on app1.domain.com we host our app. This app has a front-end you'd access by going to app1.domain.com (or any other sub-domain like app1.domain.com/my/route). The web-app, a mobile app, or a third-party service might need to fetch data, ideally from app1.domain.com/api/requested/resource. Can I host the front-end with Workers/Pages on—by default—all routes on that subdomain, but "reserve" /api/* to be used by a separate worker running the backend code?
2 Replies
veeque
veequeOP3d ago
Ideally I'd like to handle all this with wrangler.toml files for each, rather than going through the UI
Hello, I’m Allie!
Sure, Workers Routes should go by specificity, so a Worker serving requests to app1.domain.com/api/* should take priority over a Worker serving app1.domain.com/*

Did you find this page helpful?