I’m adding a file containing JSON which requires the Content-Typeapplication/json, but can not end with .json. Have made several attempts at configuring this through the netlify.toml, but no matter what it always returns text/plain.
That worked! Appreciate the help. Feels like the toml should work w/ this, but hopefully if anyone else runs into a similar issue this topic will appear
yes, ideally, I would expect the same behaviour regardless of where you set the header, I think. My knowledge isn’t super deep in this area I’m glad it’s working now, we’ll try and get some eyes on this to understand what is happening here.
I also expect the same behavior regardless of if you’re using a _headers file or a netlify.toml file.
One thing that stood out to me in the netlify.toml snippet you shared is that the Cache-Control line isn’t using the multiline string format that the docs indicate should be used for multi-value headers.
I wonder if that’s what’s causing your netlify.toml header rules to not be applied as expected.
Is the behavior any different if you use the documented multiline string format for multi-value headers like so?
It also might be useful to this thread to remark that you need to set your customer header with capitalised header values. When I tried it with content-type: "application/json" I ended up with two content-type headers
Is anyone able to share the exact code I should place in my _headers file for this?
I tried:
# a path:
/.well-known/apple-app-site-association
# headers for that path:
Content-Type: “application/json”
X-Content-Type-Options: “nosniff”
Cache-Control: “public, max-age=0”
But it still doesn’t seem to validate. My domain hosts my SPA built with angular, so I also wonder if angular’s router is missing with it some how?
Hey @sdb,
I don’t see any obvious issues with those headers. Could you please share your Netlify URL so we can take a look? As a sanity check, I’d like to at least confirm that they’re processed as part of the deploy. Thanks!
Thanks Jen, I managed to get it working I think a part of the problem was my app is a SPA (with angular) and it was catching the route. So I added a rule to my _rewrite files which seemed to fix that.
Branch.io’s validation tool says it is correct, but apple’s does not, however it still works on iOS so who knows.