Why doesn’t NGINX apply header response when serving an image?

I’ve got a problem with NGINX, serving a folder.

`server {
listen [::]:80;
server_name xyz.xyz;

location / {
  add_header 'Access-Control-Allow-Origin' '*';

  autoindex on;
  root  /directory/to/folder;


When I make a GET request for an image – server doesn’t apply response header. Why?

I expected
add_header 'Access-Control-Allow-Origin' '*';
may resolve it, just as when I serve api. I’ve also tried making another server, proxing that, and adding header on this another server.

Read more here: Source link