我正在Laravel开发护照API。我得到一个“MethodNotAllowedHttpException”。如何在Laravel中解决“MethodNotAllowedHttpException”错误?
我没有得到任何想法,有什么解决做我必须做的。
<?php
use Illuminate\Http\Request;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::post('register', 'Api\Auth\[email protected]');
Route::post('login', 'Api\Auth\[email protected]');
Route::post('refresh', 'Api\Auth\[email protected]');
Route::middleware('auth:api')->group(function() {
Route::post('logout', 'Api\Auth\[email protected]');
Route::get('posts', 'Api\[email protected]');
});
当在浏览器中访问'register',使用了'GET' ,但你的路线只允许'POST'。你可能需要'curl'或Postman来测试你的API。 – halfer
我也有同样的问题,你找到任何解决方案,请让我知道。 – Abhee