Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

RSchofield's avatar

API Route::options Not Working

Hi, I have been using Laravel for the last few months and am not attempting to create a REST API. I plan to use HATEOAS as my guideline along with the O'Reilly book "RESTful Web Services". I want to use the OPTIONS method at the root of the api. I edited the api.php and added

Route::options('/',function()
{
    return 'Hello World';
});

When I use Postman to make the call, it shows as a OPTIONS method call in the log file, but never returns "Hello World".

If I can this to Route::get then it works. Can someone tell me what I am missing?

Thanks

0 likes
1 reply
RSchofield's avatar

Found the solution.

Coming from the Apache world, this is the first time using IIS (10). I edited the applicationHost.config file and removed the following handlers lines

<add name="TRACEVerbHandler" path="*" verb="TRACE" modules="ProtocolSupportModule" requireAccess="None" />
<add name="OPTIONSVerbHandler" path="*" verb="OPTIONS" modules="ProtocolSupportModule" requireAccess="None" />

and edited the PHP_via_FastCGI handler to

<add name="PHP_via_FastCGI" path="*.php" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files\PHP\v7.2\php-cgi.exe" resourceType="Either" />

I then restarted IIS and all the routes started working. Hope this helps someone else.

Please or to participate in this conversation.