【发布时间】:2019-12-15 10:51:25
【问题描述】:
我尝试使用 API 路由,但我的路由不起作用。
当我尝试使用 http://xxxxxxx/api/v1/auth/login 登录时
服务器向我发送 404 错误。你有什么想法吗?
// Auth Endpoints
Route::group([
'middleware' => 'cors',
'prefix' => 'v1/auth'
], function ($router) {
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LogoutController@logout');
Route::post('register', 'Auth\RegisterController@register');
Route::post('forgot-password', 'Auth\ForgotPasswordController@email');
Route::post('password-reset', 'Auth\ResetPasswordController@reset');
});
// Resource Endpoints
Route::group([
'middleware' => 'cors',
'prefix' => 'v1'
], function ($router) {
Route::apiResource('todo', 'TodoController');
});
// 未找到 Route::fallback(function(){ return response()->json(['message' => 'Resource not found.'], 404); });```
【问题讨论】:
标签: laravel routes http-status-code-404