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 › ApiNoteController@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:
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
2
Answers
I suggest you to pass _method=DELETE in JSON form request parameters.
Try to call the API like this: