Php NotFoundHttpException Laravel/Lumen

Php NotFoundHttpException Laravel/Lumen,php,laravel,jwt,Php,Laravel,Jwt,我正在尝试创建一个项目,使用Lumen对2个用户(患者和医生)进行多重身份验证 每次我想运行服务器时,都会出现以下错误: 不允许使用HTTP 405方法 这是我的Corsmidlware: class-corsmidware { /** *处理传入的请求。 * *@param\light\Http\Request$Request *@param\Closure$next *@返回混合 */ 公共函数句柄($request,Closure$next) { //拦截选项请求 如果($request-

我正在尝试创建一个项目,使用Lumen对2个用户(
患者
医生
)进行多重身份验证

每次我想运行服务器时,都会出现以下错误:

不允许使用HTTP 405方法

这是我的
Corsmidlware

class-corsmidware
{
/**
*处理传入的请求。
*
*@param\light\Http\Request$Request
*@param\Closure$next
*@返回混合
*/
公共函数句柄($request,Closure$next)
{
//拦截选项请求
如果($request->isMethod('OPTIONS')){
$response=响应('',200);
}否则{
//将请求传递给下一个中间件
$response=$next($request);
}
//向响应中添加标题
$response->header('Access-Control-Allow-Methods','HEAD、GET、POST、PUT、PATCH、DELETE');
$response->header('Access-Control-Allow-Headers',$request->header('Access-Control-request-Headers');
$response->header('Access-Control-Allow-Origin','*');
$response->header('Access-Control-Expose-Headers','Location');
//发送它
返回$response;
}
}
My
web.php

$router->group(['prefix'=>'patient'],函数()使用($router){
$router->post('register','Patient/PatientAuthController@register');
$router->post('login','Patient/PatientAuthController@login');
$router->get('view-profile','Patient'/PatientAuthController@viewProfile');
$router->get('logout','Patient'/PatientAuthController@logout');
$router->post('refresh-token','Patient'/PatientAuthController@refreshToken');
});
我的控制器:

      protected $patient;
    protected $utilityService;


    public function __construct()
    {
        $this->middleware("auth:patient",['except'=>['login','register']]);
        $this->patient = new Patient;
        $this->utilityService = new UtilityService;
    }


    public function register(PatientRegisterRequest $request)
   {
       $password_hash = $this->utilityService->hash_password($request->password);
       $this->patient->createPatient($request,$password_hash);
       $success_message = "registration completed successfully";
    return  $this->utilityService->is200Response($success_message);
   }


    /**
     * Get a JWT via given credentials.
     *
     * @param  Request  $request
     * @return Response
     */
    public function login(LoginRequest $request)
    {
        $credentials = $request->only(['email', 'password']);

        if (! $token = Auth::guard('patient')->attempt($credentials)) {
            $responseMessage = "invalid username or password";
            return $this->utilityService->is422Response($responseMessage);
         }
         

        return $this->respondWithToken($token);
    }


    public function viewProfile()
    {
        return response()->json([
            'success'=>true,
            'patient' => Auth::guard('patient')->patient()
            ]
            , 200);
    }

    
   /**
     * Log the application out (Invalidate the token).
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function logout()
    {
        try {
           
             $this->logUserOut();

        } catch (TokenExpiredException $e) {
            
            $responseMessage = "token has already been invalidated";
            $this->tokenExpirationException($responseMessage);
        } 
    }

    
    public function logUserOut()
    {
        Auth::guard('patient')->logout();
        $responseMessage = "successfully logged out";
      return  $this->utilityService->is200Response($responseMessage);
    }


    public function tokenExpirationException($responseMessage)
    {
        return $this->utilityService->is422Response($responseMessage);
    }

    /**
     * Refresh a token.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function refreshToken()
    {
        try
         {
            return $this->respondWithToken(Auth::guard('patient')->refresh());
        }
         catch (TokenExpiredException $e)
         {
            $responseMessage = "Token has expired and can no longer be refreshed";
            return $this->tokenExpirationException($responseMessage);
        } 
    }
我已经在app.php中注册了middlware,但它仍然不起作用

我还检查了.htaccess文件中的重写引擎


如果有任何帮助,我们将不胜感激。

你能分享你的
耐心控制器的代码吗
我刚刚编辑了这篇文章,谢谢你的回复@请不要共享图片,因为图片可能会掉下来,帖子将失去所有意义,请复制粘贴您的代码,而不要共享图片。还有,你想访问哪个URL?好的,伙计,我会尝试访问,顺便说一句,我想访问localhost:8000/patient/register来测试一下。我从中看到的唯一一件事是,你可能正在发送GET请求和你的端点异常POST。