#1843·jwt-auth

The GET method is not supported for this route. Supported methods: POST - Laravel 5.8

Author: pereiracinthiagCreated Jul 9, 2019Updated May 13, 2025

The GET method is not supported for this route. Supported methods: POST

I am trying to get a response in dev.site.com.br/api/auth/me and I have the error Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException: The GET method is not supported for this route. Supported methods: POST. in file C:\\xampp\htdocs\rnlinked\api\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php on line 256

I am using laravel 5.8 and JWT 1.0 The login method works fine, but the me or logout methods doesn't work.

My environment

| Bug? | yes | Framework | Laravel | Framework version | Laravel Framework 5.8.27 | Package version | "tymon/jwt-auth": "dev-develop" | PHP version | 7.3.3

Below are my codes:

AuthController.php

<?php

namespace App\Http\Controllers\Api;

use App\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;


class AuthController extends Controller
{
    
    public function __construct()
    {
        $this->middleware('auth:api', ['except' => ['login']]);
    }

    public function login()
    {
        $credentials = request(['email', 'password']);

        if (! $token = auth()->attempt($credentials)) {
            return response()->json(['error' => 'Invalid Login'], 401);
        }

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

    public function me()
    {
        return response()->json(auth()->user());
    }

    public function logout()
    {
        auth()->logout();

        return response()->json(['message' => 'Successfully logged out']);
    }


    public function refresh()
    {
        return $this->respondWithToken(auth()->refresh());
    }

    protected function respondWithToken($token)
    {
        return response()->json([
            'access_token' => $token,
            'token_type' => 'bearer',
            'expires_in' => auth()->factory()->getTTL() * 60
        ]);
    }
    
}

In routes/api.php

Route::group([

    'middleware' => 'api',
    'prefix' => 'auth'

], function ($router) {

    Route::post('login', 'Api\AuthController@login')->name('login');
    Route::post('logout', 'Api\AuthController@logout')->name('logout');
    Route::post('refresh', 'Api\AuthController@refresh')->name('refresh');
    Route::post('me', 'Api\AuthController@me')->name('me');

});

I am using postman and I do a POST request on logout or me or refresh and they get the same error. Only the login method works.