2

I have developed web application using Laravel 10 and nginx, I want to allow only post method for specific route

Route::post('/otpgen', 'App\Http\Controllers\controller@otpgen');

I have following code in my app\Exception\Handler.php

public function render($request, Throwable $e)
    {
        if ($e instanceof MethodNotAllowedHttpException) {
            return abort(404);
        }
        
        return parent::render($request, $e);
    }

enter image description here

as allowed method is POST, for all other request method like HEAD,GET,DELETE i am getting 405 method not allowed response code which is correct, but as you can see in image for OPTIONS method i am always getting 200 instead of 405, I want 405 for OPTIONS method too.

user3782114
  • 542
  • 2
  • 7
  • 22

0 Answers0