Could https://docs.netlify.com/routing/headers/#syntax-for-the-headers-file be updated to prevent others being tripped up by the headers issue? It doesn’t really mention the limitations, and I’m still not really sure what they are (can * only be at the end of a rule?). Also, my deploy says “All header rules deployed without errors.” - it seems like this would be a good place to point out if a header rule isn’t supported.
Hi, @jakearchibald, there is an open feature request for the docs change update about Large Media limitations with custom headers based on the other topic you linked to. We’ll post an update there (and here) when the docs are updated.
I get that there isn’t an example of it being used to match file extensions, but I don’t think the absence of an example suggests it doesn’t work. Otherwise, that would suggest that :placeholder doesn’t work at all, since there isn’t a single example of it on that page. I don’t think that’s the case, and I don’t think that’s how folks interpret documentation.
I think it’s better to explain how it works, rather than give an incomplete description, then try and fill in the gaps with exceptions. If I’ve understood how it works correctly, I think this describes it:
You can use *at the end of a pattern to match anything that appears afterwards. This makes the pattern a “starts with” match. So /foo/* will match any URL that starts with/foo/, including /foo/ itself, but also /foo/bar/ and /foo/hello/world/yo.html.
Warning: Although * can only be used at the end of a pattern, Netlify does not validate this. Instead, any pattern characters after the first * are simply discarded. Netlify will silently accept a rule like /posts/*.jpg, but it will not behave as you intend. It will be interpreted as /posts/*, so the rule will apply for /posts/cat.jpg, but it will also apply for /posts/data.json.
You need a strong warning here, because no one would include a rule like /posts/*.jpg expecting the .jpg to be ignored.
You wouldn’t need the strong warning if Netlify caught the issue at build time, and failed the build with a message like “Header rule error: * can only appear at the end of a pattern, see [url] for more details”.
This is my preference, as I would have discovered the issue at build time, rather than in production.