title: How to make nginx CORS configuration work when server returns error?
body: <p>I want to add CORS to my server. </p>
  
  <p>I have configured my nginx according to this: <a href="https://michielkalkman.com/snippets/nginx-cors-open-configuration.html" rel="noreferrer">https://michielkalkman.com/snippets/nginx-cors-open-configuration.html</a></p>
  
  <p>It seems to work fine when the server returns 200. 
  However, if the server returns something else, like 400 when the request is wrong, or 500 if internal error, the browser shows the <code>No 'Access-Control-Allow-Origin' header</code> instead of reaching the error handler like it should. </p>
  
  <p>What configuration am I missing to make it work?</p>