Pre-flight OPTIONS request to API results in exception


#1

Playing around with writing a web app that utilises the (awesome) Warcraft Logs API. Unfortunately, as it is a cross-origin request, the browser’s security kicks in and does a pre-flight OPTIONS request before the GET request, and this OPTIONS request (despite returning a 200 success status code) seems to be failing.

You can recreate by using Postman or something similar to make an OPTIONS request to:

https://www.warcraftlogs.com/v1/zones?api_key=YOUR_API_KEY_HERE

The response is:

<html><h2>Unhandled Exception</h2>
<h3>Message:</h3>
<pre>Call to a member function call() on null</pre>
<h3>Location:</h3>
<pre>/var/app/current/laravel/laravel.php on line 165</pre>

#2

If anyone else has this problem, you might be able to get around it by removing any custom headers in your GET request (for example, Angular was setting a couple of headers by default when using the Http module, so I passed in a blank Headers object to counteract this).

Ideally, the API would be configured to accept OPTIONS requests, but I can see why it might be a low priority thing.