do you have the correct Route::delete route for the request path declared in your web.php file??
Dec 15, 2021
19
Level 23
Send a delete request and redirect back, 405 error
I send a delete request from Front end:
this.$inertia.visit('/test/100', {
method: 'delete',
onSuccess: () => {
this.$notify.success('success')
},
onError: () => {
this.$notify.error('failed')
},
})
and at backend, I delete the data and redirect back:
public function destroy($ids){
$this->model->whereIn('id', explode(',', $ids))->delete();
return redirect('/test');
}
and an error occured, it says
Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The DELETE method is not supported for this route. Supported methods: GET, HEAD, POST.
http://127.0.0.1:9998/test
aren't the request method of redirection supposed to be 'GET'? instead of 'DELETE'? How this work?
Level 102
@russellxu I got it working. The example is missing the Inertia middleware :)
https://inertiajs.com/server-side-setup#middleware
Add \Inertia\Middleware::class to the 'web' middleware group in Kernel.php
1 like
Please or to participate in this conversation.


