我正在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