1. 18
  1.  

  2. 2

    Another option would be simply use example.com/api/ instead of api.example.com and don’t bother :)

    1. 1

      In many cases this effectively doubles the latency of your API for all browser clients. From the end user’s point of view, your performance is halved!

      Only true for the actual HTTP and transport part of the request latency, and most requests will be performing some persistence access, business logic and other blocking operations so most real-world cases won’t incur such a drastic performance hit. From the end user’s point of view, the OPTIONS request is a mere fraction of the actual API operation.

      That being said, this is definitely a worthwhile thing to know when dealing with high traffic scenarios and with platforms billed by request counts.