路由问题:访问接口报404错误

出走半生

问题描述

在前台控制器文件上面添加一层后访问接口报404错误

程序代码

config/route.php

Route::group('/v1/user', function () {
    Route::post('/login', [app\controller\v1\UserController::class,'login']);  //登录

});

app/UserController/v1/UserController.php

<?php
namespace app\controller\v1;
class UserController{
    public function login(Request $request){
        return json(['code' => 0,'msg' =>'登录成功','data'=>[]]);
    }
}

报错信息

<html>
<head>
    <title>404 Not Found - webman</title>
</head>
<body>
<center>
    <h1>404 Not Found</h1>
</center>
<hr>
<center>webman</center>
</body>
</html>

截图报错信息里报错文件相关代码


524 3 1
3个回答

pidanshourou

我试了一下你的,不存在你说的那种情况,仔细检查一下吧

ersic

关闭默认路由试试呢

如果你想关闭默认路由,在配置文件 config/route.php里最后一行加上如下配置:
Route::disableDefaultRoute();

小W

重启了?

  • 暂无评论
🔝