I
I
Ilya Vegner2019-12-11 10:19:11
Laravel
Ilya Vegner, 2019-12-11 10:19:11

Why do I get 404 status when I request a remote machine?

I wrote a laravel back end, tested it on a local machine and everything works, but when I deployed this project to a remote machine, when I try to make a request, I get a 404 status with an error in response
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
web.php

Route::get('api/chats', '[email protected]');
Route::post('api/message/send', '[email protected]');
Route::post('api/message/all', '[email protected]');

Controllers/ChatController
class ChatController extends Controller
{
    public function index(Request $request)
    {
        $userId = $request->attributes->get('user_id');
        $user = User::find($userId);
        $chats = $user->chats;

        foreach($chats as $chat) {
            if ($chat->type === 'single') {
                $toUser = ConversationUser::where('conversation_id', $chat->id)
                    ->where('user_id', '!=', $userId)
                    ->first();
                $sender = User::find($toUser->user_id);
                $chat->user_id = $sender->id;
                $chat->title = $sender->name;
                $chat->reload = false;
            }
        }

        return response(Answer::jsonAnswer(array('chats' => $chats)));
    }
}

With what it can be connected ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question