Problem with Laravel API in production

Asked

Viewed 167 times

1

I have deployed an API in Laravel. The problem that is occurring is the following: the online API always returns me '200 ok', without at least getting to the login controller. With this same API, I ran the test on localhost and it worked. I need to set some more permission?

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

1 answer

-1

It would be interesting put the code of the method of its controller, because depending on the conditions used it can pass the method without performing any operation, until it arrives in Return, so it is giving 200.

Ex:

{
   $dados = (object) $request->all();
   $usuario = usuairo::where('email',$dados->email)->first();
   if($usuario){
      if($this->testeUsuarioSenha($dados))
         return Response::json(['message' => 'Login realizado com sucesso'], 200);
      else
         return Response::json(['message' => 'Não encontrado'], 404);
   } 
   return '';

}

Looking at the above code, do you agree that for emails that do not exist in the database will return http 200? Finally to help would need more information.

On the server run the following command and analyze your routes:

php artisan route:list

Another interesting point to observe, is in production run also.

    php artisan route:cache

Browser other questions tagged

You are not signed in. Login or sign up in order to post.