How do Apps, Workers Routes and Page Rules get prioritized on a request?

I’m new to Workers, and I’m running into lack of knowledge regarding the way requests are routed in Cloudlflare, specifically in how it prioritizes Apps, worker routes, and page rules in handling a request.

Here’s my specific scenario-
I’m using the Cassette app on a client site, which effectively proxies an S3 bucket under a subdomain.
Cassette registers a subdomain in the DNS, e.g. assets.mysite.com. Overall the app works very well however it does not have a means to configure a /robots.txt which my client requires.

I expected this would be an easy fix with a Worker, however my Worker Route of e.g. *assets.mysite.com/robots.txt isn’t getting hit. It appears the app intercepts all traffic for that subdomain directly before the worker routes get resolved?

I’ve also created a page rule for that path to disable apps, but it’s still not triggering my worker.

So 2 questions-

  1. How can I overcome this and ensure that my robots.txt is delivered for https://assets.mysite.com/robots.txt
  2. Is there a diagram somewhere that illustrates how a request is processed?

You can show the route your request takes through the Cloudflare pipeline using Trace…

https://dash.cloudflare.com/?to=/:account/trace

2 Likes

Thanks @sjr that’s very helpful- in my case it’s not showing any trace information regarding apps or workers, I only see page rule matches.

I did notice that if I have my page rule for disabling apps, the trace indicates a match but doesn’t display anything. If I download the JSON, I can see a blank step_name.

image

Disabling that rule, trace matches my full set of rules, but it still does not seem to be executing my worker.

If I create a different worker route, e.g. *mysite.com/hello then I get a successful match and worker run on my main site, but the subdomain route never appears to be run.

Or, perhaps, my worker is running and then its response is being overwritten by the Cassette app? Is there a way to have a worker prevent any subsequent steps from happening?

With the current trace beta I’m unable to tell when my workers or the apps are executing. :thinking:

Does anyone have a reference that could help me debug this, or an approach that will let my worker run on the app-managed subdomain?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.