1

In my routes.php, when I have:

    Route::delete('page/{id}', function ($id)
    {
        return "deleting $id";
    });

And I send a delete or get request using Postman, This throws a MethodNotAllowedHttpException.

When I change routes.php:

    Route::get('page/{id}', function ($id)
    {
        return "deleting $id";
    });

It responds the string deleting... in response to GET, DELETE and PUT! But the HTTP code is 403.

It just throws a MethodNotAllowedHttpException on a POST request.

This problem seems to occur only on remote server and it works as expected on localhost.

Is there anything in Laravel that maybe redirects or changes methods to GET?

0

2 Answers 2

1

It's because Apache doesn't allow DELETE requests, and that's why the response code is a "403 forbidden".

Add this to .htaccess after the Laravel default codes:

<Limit DELETE>
  Order deny,allow
  Allow from all
</Limit>

see this answer: https://stackoverflow.com/a/1402480/2543240

Sign up to request clarification or add additional context in comments.

Comments

0

Try to add this to your form, above delete button:

{!! method_field('DELETE') !!}
<input type="hidden" name="_method" value="DELETE">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.