My goal is to match everything like /_astro/confident-crow.3c210aae.svg and /_astro/james-pixelated.2abe0d5f.png. It doesn’t seem to be matching anything.
Are multiple :placeholders supported? If not, how else would you express something that matches these fingerprinted files, but doesn’t match something like /_astro/foo.bar/baz.js?
If it were possible to use a regular expression, I would use
Welcome to the forums and thanks so much for reaching out. Where is your netlify.toml? Is this in the root directory of your project and located in the same package.json otherwise it won’t be recognized by our system. If this doesn’t help can you please give a read of our documentation? Custom headers | Netlify Docs
If I define the headers the workspace root, then I’ll get the same values for every application, which is undesirable.
The docs do say
When you declare headers in a _headers file stored in the publish directory or a Netlify configuration file, the headers are global for all builds and cannot be scoped for specific branches or deploy contexts.
But this isn’t about branches or deploy contexts.
Edit
I tried moving the [[headers]] to the root netlify.toml in preview build 22, but they’re still not working.
That didn’t work. Nor did that same file in apps/www/_headers.
I also figured that Netlify might have a problem with *.:fingerprint.:ext (despite there being no limitation listed in the docs), so I tried this in both locations:
Your comment on that issue seems like an assertion, and an incorrect one. Multiple placeholders work perfectly fine. I’d recommend deleting (or editing) the comment from that issue to avoid any confusion. Check out the repo:
That suggests that * alone doesn’t cause the rest of the path to be completely ignored.
Most router frameworks I’ve worked with (Rails, Ember, React-Router, Astro, Jekyll) have these same concepts of “glob” and “placeholder.” They all have the same contract. They turn a * (glob) into a .+ RegExp and a :placeholder into a [^\/]+ RegExp. Thus, I would expect /*/:file.js to match the same things as /^\/.+\/[^\/]+\.js$/, and /test/*.:fingerprint.css to match the same things as /^\/test\/.+\.[^\/]+\.css$/.
I don’t see that happening on Netlify. Our behaviour has been established that way for years, and changing that suddenly would mean a breaking change for not sure how many sites.
A simple rule like I mentioned before:
* will ignore everything after it, use placeholders if you don’t want wildcard
If that “rule” were correct, /test/*.:fingerprint.css would match the same things as /test/*, which it does not. https://frabjous-halva-7b75f1.netlify.app/test/foo.abc123.txt should have is-test: true from
See also Cloudflare’s documentation for _headers, which specifies support for things like /*.jpg. This is also consistent with Unix glob (in semantics, but not syntax).