Enable CORS for Nginx

Whom have worked with cross-origin HTTP requests knows that one of the actions to make this working is enable CORS in API’s webserver .

As I work with Nginx, the code that warns browsers (Firefox e Chrome) and allow pre-flight requests is presented below:

https://gist.github.com/6398833248000894b05b

The flow of this browsers is: making a pre-flight request to test the webserver, before making the real request. The code above allow the cross-origin request flow goes ahead. You will need to implement this code between “location” block.

More informations in Enable CORS and here. Hope this useful.

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *