Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In your javascript client you're making an OPTIONS request to <strong>/user/auth</strong>, but in your PHP code you're only accepting POST requests through this endpoint.</p> <p>If you want your API to accept OPTIONS method you should have something like this in your code:</p> <pre><code>$app-&gt;options('/user/auth', function () use ($app) { //code here }); </code></pre> <p>Or, if you want to handle multiple HTTP methods in the same function:</p> <pre><code>$app-&gt;map('/user/auth', function () use ($app) { if ($app-&gt;request()-&gt;isOptions()) { //handle options method } else if ($app-&gt;request()-&gt;isPost()) { //handle post method } })-&gt;via('POST', 'OPTIONS'); </code></pre> <p>Keep in mind that the OPTIONS method, <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html" rel="noreferrer">according to W3C</a>:</p> <blockquote> <p>[...] represents a request for information about the communication options available on the request/response chain identified by the Request-URI. This method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval.</p> </blockquote> <p>Alternatively, just change your client's code to make a POST request instead of OPTIONS request. It's easier and makes more sense than authenticating a user through the OPTIONS method. In zepto.js it would be something like this:</p> <pre><code>$.post('/user/auth', { foo: 'bar' }, function(response){ console.log(response); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload