Middleware OK on `pages.dev`, not on custom domain?

I tried _middleware.js stuff with CF Pages, in an attempt to use it instead of an existing CF Worker. The middleware worked perfectly on the pages.dev version — but, on the custom-domain version from that pages.dev, only the HTML files were affected even though the middleware was supposed to apply for all routes and files (location: functions/_middleware.js, thus presumably for all routes).

To be more specific: on the pages.dev version, a number of custom headers (such as for caching) were added to a variety of file types, including CSS and image files; but, on the custom-domain version, this worked for only the HTML files.

Is there something special I have to do in the domain’s DNS, or elsewhere, to make the middleware work properly on the custom domain, too? (And I did remove the custom domain’s routes from the Worker for the test, so the Worker shouldn’t have been interfering.)

The pages.dev domain = static-site-2to.pages.dev
The custom domain = brycewray.com

Note: I had to re-add the custom domain routes to the Worker and take the _middleware.js file out of the project in order to regain the previous functionality, at least until I could learn from you folks why the middleware file wouldn’t work on the custom domain. Let me know if/when you want me to restore the test setup (assuming GitHub is stable at the time, that is 😄 ).
Was this page helpful?