Search code examples
phplaravelapachehttplaragon

How to allow method DELETE in apache Laragon - laravel 10?


I have a vanilla installation of Laragon and a vanilla installation of Laravel v10 with Jetstream, i am using it as an API i have a separate project in Vue that consumes said API, all the login works.

I am using axios and it works when i am saving, i created a model and a controller, so i have a NoteController with the destroy function:

    public function destroy(Note $note)
    {
        
        $note->delete();

        return response()->noContent();
    }

when i do php artisan route:list --name=note i can see the delete route:

DELETE   api/note/{note}................. note.destroy › Api\NoteController@destroy

i am using in api.php :

Route::apiResource('/note', NoteController::Class);

In vue i am doing (where item is a note object):

api.delete<Note>('/api/note', { data: item })

i am getting a 405 Method Not Allowed:

message
: 
"The DELETE method is not supported for route api/note. Supported methods: GET, HEAD, POST."

i can see in the response headers:
enter image description here

I tried adding the following to httpd.conf inside the <Directory "F:/laragon/www"> tag:

<Limit GET POST PUT DELETE>
    Allow from all
</Limit>

and restarted Laragon, i still get the 405.

I tried the other solutions from other questions in regards to Laravel config but i still have the error, and i see the route in route:list


Solution

  • Try to call the API like this:

    api.delete<Note>(`/api/note/${item.id}`)
    

    (Edit: Removed second parameter of api call: {_method: 'delete'})