1

I'm trying to add a cors header using nginx proxy Docker container https://github.com/jwilder/nginx-proxy.

I've create a config file containing the line:

add_header 'Access-Control-Allow-Origin' '*' always

I've used a volume to pass this in through the docker-compose file at runtime so it appears at /etc/nginx/vhost.d/default

But the resulting header in the api response contains two values separated by a comma: http://myapi-domain.com, *

This makes cross-domain requests fail with the error: header contains multiple values but only one is allowed.

Think I'm following the documentation correctly...Is this a fault or is there a way to over-ride so there's only one value in the header?

Ben Gannaway
  • 1,053
  • 1
  • 14
  • 28

1 Answers1

1

If anyone else is getting CORS errors with this nginx-proxy Docker, check the logs properly as this turned out to be a max_body_size error in the nginx. The browser saw it as a CORS error for some reason. max body size can be easily configured using the same method I used above to modify the headers

Ben Gannaway
  • 1,053
  • 1
  • 14
  • 28