How to fix Laravel “Post method is not supported for this route”?Laravel 5.1 - Trying to Prevent 302 URL Redirect Using Auth Boilerplate as APIlaravel 5.1 authlogin where are those controller methods?Laravel: Ajax post request routinglaravel calling route from a controllerLaravel 5.4 POST to API redirect 302 rather than returning validation errorHow can I create a token for a Password Grant Client using Laravel Passport?Laravel 5.4 post route returns no responseLaravel 5.6 pass oauth/token hangingLaravel passport public api routesLaravel: MethodNotAllowedHttpException: The GET method is not supported for this route. Supported methods: POST

If the pressure inside and outside a balloon balance, then why does air leave when it pops?

How can powerful telekinesis avoid violating Newton's 3rd Law?

Are athlete's college degrees discounted by employers and graduate school admissions?

What is the theme of analysis?

how to fix error not showing in magento 2

Parsing text written the millitext font

Should I explain the reasons for gaslighting?

What is this metallic object with teeth in mouth, screw to tighten and a handle?

Is it true that "only photographers care about noise"?

Why did the Death Eaters wait to reopen the Chamber of Secrets?

Can you open the door or die? v2

Which are the methodologies for interpreting Vedas?

What plausible reason could I give for my FTL drive only working in space

Approach sick days in feedback meeting

Why does there seem to be an extreme lack of public trashcans in Taiwan?

Why is the concept of the Null hypothesis associated with the student's t distribution?

What did the 8086 (and 8088) do upon encountering an illegal instruction?

How do I change my LaTex document to follow some Word requirements?

Oxford comma with nonessential phrases

What would the consequences be of a high number of solar systems being within close proximity to one another?

How to represent jealousy in a cute way?

Placement of positioning lights on A320 winglets

Savage Road Signs

Dedicated bike GPS computer over smartphone



How to fix Laravel “Post method is not supported for this route”?


Laravel 5.1 - Trying to Prevent 302 URL Redirect Using Auth Boilerplate as APIlaravel 5.1 authlogin where are those controller methods?Laravel: Ajax post request routinglaravel calling route from a controllerLaravel 5.4 POST to API redirect 302 rather than returning validation errorHow can I create a token for a Password Grant Client using Laravel Passport?Laravel 5.4 post route returns no responseLaravel 5.6 pass oauth/token hangingLaravel passport public api routesLaravel: MethodNotAllowedHttpException: The GET method is not supported for this route. Supported methods: POST






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am trying to create authentication using Laravel Passport, I have configured everything the right way as mentioned in the official documentation. The GET Route method works perfectly (see the code below), but when I try the POST Route method I always get this error:




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




P.S: I am using Postman for the test.



I have tried to include CSRF token but nothing happens, and I get the same error.



Controller



class AuthController extends Controller

public function register(Request $request)
string

public function login(Request $request)

$user = User::where('email', $request->email)->first();

if ($user)
if (Hash::check($request->password, $user->password))
$token = $user->createToken('Laravel Password Grant Client')->accessToken;
$response = ['token' => $token];

return response($response, 200);
else
$response = "Password missmatch";

return response($response, 422);


else
$response = 'User does not exist';

return response($response, 422);



public function logout(Request $request)

$token = $request->user()->token();
$token->revoke();
$response = 'You have been succesfully logged out!';

return response($response, 200);




Routes



Route::middleware('auth:api')->get('/user', function (Request $request) 
return $request->user();
);

Route::post('/login', 'ApiAuthController@login')->name('login.api');
Route::post('/register', 'ApiAuthController@register')->name('register.api');


I expect to get user registered, and it returns the auth token, but it shows me
"The POST method is not supported for this route. Supported methods: GET, HEAD."










share|improve this question
























  • "The POST method is not supported for this route. Supported methods : GET, HEAD" -- which route did you hit of the three?

    – Bagus Tesa
    Mar 24 at 23:55











  • The first route should be in api.php, right? So the url should be with a prefix api/user. I think you haven't included all information in your question.

    – senty
    Mar 25 at 0:55











  • @senty yes I had to make the routes in api.php ... It works perfectly now thank you so much

    – Mouad Benyamna
    Mar 25 at 19:55

















0















I am trying to create authentication using Laravel Passport, I have configured everything the right way as mentioned in the official documentation. The GET Route method works perfectly (see the code below), but when I try the POST Route method I always get this error:




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




P.S: I am using Postman for the test.



I have tried to include CSRF token but nothing happens, and I get the same error.



Controller



class AuthController extends Controller

public function register(Request $request)
string

public function login(Request $request)

$user = User::where('email', $request->email)->first();

if ($user)
if (Hash::check($request->password, $user->password))
$token = $user->createToken('Laravel Password Grant Client')->accessToken;
$response = ['token' => $token];

return response($response, 200);
else
$response = "Password missmatch";

return response($response, 422);


else
$response = 'User does not exist';

return response($response, 422);



public function logout(Request $request)

$token = $request->user()->token();
$token->revoke();
$response = 'You have been succesfully logged out!';

return response($response, 200);




Routes



Route::middleware('auth:api')->get('/user', function (Request $request) 
return $request->user();
);

Route::post('/login', 'ApiAuthController@login')->name('login.api');
Route::post('/register', 'ApiAuthController@register')->name('register.api');


I expect to get user registered, and it returns the auth token, but it shows me
"The POST method is not supported for this route. Supported methods: GET, HEAD."










share|improve this question
























  • "The POST method is not supported for this route. Supported methods : GET, HEAD" -- which route did you hit of the three?

    – Bagus Tesa
    Mar 24 at 23:55











  • The first route should be in api.php, right? So the url should be with a prefix api/user. I think you haven't included all information in your question.

    – senty
    Mar 25 at 0:55











  • @senty yes I had to make the routes in api.php ... It works perfectly now thank you so much

    – Mouad Benyamna
    Mar 25 at 19:55













0












0








0








I am trying to create authentication using Laravel Passport, I have configured everything the right way as mentioned in the official documentation. The GET Route method works perfectly (see the code below), but when I try the POST Route method I always get this error:




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




P.S: I am using Postman for the test.



I have tried to include CSRF token but nothing happens, and I get the same error.



Controller



class AuthController extends Controller

public function register(Request $request)
string

public function login(Request $request)

$user = User::where('email', $request->email)->first();

if ($user)
if (Hash::check($request->password, $user->password))
$token = $user->createToken('Laravel Password Grant Client')->accessToken;
$response = ['token' => $token];

return response($response, 200);
else
$response = "Password missmatch";

return response($response, 422);


else
$response = 'User does not exist';

return response($response, 422);



public function logout(Request $request)

$token = $request->user()->token();
$token->revoke();
$response = 'You have been succesfully logged out!';

return response($response, 200);




Routes



Route::middleware('auth:api')->get('/user', function (Request $request) 
return $request->user();
);

Route::post('/login', 'ApiAuthController@login')->name('login.api');
Route::post('/register', 'ApiAuthController@register')->name('register.api');


I expect to get user registered, and it returns the auth token, but it shows me
"The POST method is not supported for this route. Supported methods: GET, HEAD."










share|improve this question
















I am trying to create authentication using Laravel Passport, I have configured everything the right way as mentioned in the official documentation. The GET Route method works perfectly (see the code below), but when I try the POST Route method I always get this error:




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




P.S: I am using Postman for the test.



I have tried to include CSRF token but nothing happens, and I get the same error.



Controller



class AuthController extends Controller

public function register(Request $request)
string

public function login(Request $request)

$user = User::where('email', $request->email)->first();

if ($user)
if (Hash::check($request->password, $user->password))
$token = $user->createToken('Laravel Password Grant Client')->accessToken;
$response = ['token' => $token];

return response($response, 200);
else
$response = "Password missmatch";

return response($response, 422);


else
$response = 'User does not exist';

return response($response, 422);



public function logout(Request $request)

$token = $request->user()->token();
$token->revoke();
$response = 'You have been succesfully logged out!';

return response($response, 200);




Routes



Route::middleware('auth:api')->get('/user', function (Request $request) 
return $request->user();
);

Route::post('/login', 'ApiAuthController@login')->name('login.api');
Route::post('/register', 'ApiAuthController@register')->name('register.api');


I expect to get user registered, and it returns the auth token, but it shows me
"The POST method is not supported for this route. Supported methods: GET, HEAD."







php laravel authentication oauth






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 0:13









Karl Hill

3,85632546




3,85632546










asked Mar 24 at 23:37









Mouad BenyamnaMouad Benyamna

83




83












  • "The POST method is not supported for this route. Supported methods : GET, HEAD" -- which route did you hit of the three?

    – Bagus Tesa
    Mar 24 at 23:55











  • The first route should be in api.php, right? So the url should be with a prefix api/user. I think you haven't included all information in your question.

    – senty
    Mar 25 at 0:55











  • @senty yes I had to make the routes in api.php ... It works perfectly now thank you so much

    – Mouad Benyamna
    Mar 25 at 19:55

















  • "The POST method is not supported for this route. Supported methods : GET, HEAD" -- which route did you hit of the three?

    – Bagus Tesa
    Mar 24 at 23:55











  • The first route should be in api.php, right? So the url should be with a prefix api/user. I think you haven't included all information in your question.

    – senty
    Mar 25 at 0:55











  • @senty yes I had to make the routes in api.php ... It works perfectly now thank you so much

    – Mouad Benyamna
    Mar 25 at 19:55
















"The POST method is not supported for this route. Supported methods : GET, HEAD" -- which route did you hit of the three?

– Bagus Tesa
Mar 24 at 23:55





"The POST method is not supported for this route. Supported methods : GET, HEAD" -- which route did you hit of the three?

– Bagus Tesa
Mar 24 at 23:55













The first route should be in api.php, right? So the url should be with a prefix api/user. I think you haven't included all information in your question.

– senty
Mar 25 at 0:55





The first route should be in api.php, right? So the url should be with a prefix api/user. I think you haven't included all information in your question.

– senty
Mar 25 at 0:55













@senty yes I had to make the routes in api.php ... It works perfectly now thank you so much

– Mouad Benyamna
Mar 25 at 19:55





@senty yes I had to make the routes in api.php ... It works perfectly now thank you so much

– Mouad Benyamna
Mar 25 at 19:55












1 Answer
1






active

oldest

votes


















0














This line should be in api.php



Route::middleware('auth:api')->get('/user', function (Request $request) 
return $request->user();
);





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329622%2fhow-to-fix-laravel-post-method-is-not-supported-for-this-route%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    This line should be in api.php



    Route::middleware('auth:api')->get('/user', function (Request $request) 
    return $request->user();
    );





    share|improve this answer



























      0














      This line should be in api.php



      Route::middleware('auth:api')->get('/user', function (Request $request) 
      return $request->user();
      );





      share|improve this answer

























        0












        0








        0







        This line should be in api.php



        Route::middleware('auth:api')->get('/user', function (Request $request) 
        return $request->user();
        );





        share|improve this answer













        This line should be in api.php



        Route::middleware('auth:api')->get('/user', function (Request $request) 
        return $request->user();
        );






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 19:57









        sentysenty

        4,243859142




        4,243859142





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55329622%2fhow-to-fix-laravel-post-method-is-not-supported-for-this-route%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해