Custom Headers for 404 Responses?

I would like to modify the response headers for 404 pages. Specifically, to change the content-type of the 404 to “application/json”.

Here’s the regular, 200-served content:

I would like the 404 to follow suit: , but it serves text/html no matter what config I try. Is this even possible to configure?

From my netlify.toml file:

  for = "/lists/*"
    content-type = "application/json"
    Access-Control-Allow-Origin= "*"

  from = "/:endpoint"
  to = "/lists/:endpoint.json"
  status = 200

Hi, welcome back to the forums!

Have you tried using a Serverless Function? You can set the desired response headers and return a JSON response with the appropriate status code?

Thanks, that’s a creative idea. Hoped for something simpler, but that might work.