I have two routes in laravel api routes:
Route::get('/user','Api\PassportController@getUser')->name('api.user.show');
Route::put('/user','Api\PassportController@update')->name('api.user.update');
But method put it does not work correctly in laravel 5.6 (I send data in body request but laravel resource is empty), so i send POST method with _method = put param, and laravel redirects to get path using 301 redirect, in my localhost enviroment works fine but in apache centos server doesn't work.
When i change the routes like
Route::get('/user','Api\PassportController@getUser')->name('api.user.show');
Route::put('/user/update','Api\PassportController@update')->name('api.user.update');
Work's fine.
What is my mistake?
the issue is that you are not putting the csrf token in you form you can do that by putting {{ csrf_field() }}
inside the form .
looking at you code and I'm guessing that you are making an RESTfull API so the best way is to use larave passport
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.