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;
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
add a comment |
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
"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 inapi.php, right? So the url should be with a prefixapi/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
add a comment |
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
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
php laravel authentication oauth
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 inapi.php, right? So the url should be with a prefixapi/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
add a comment |
"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 inapi.php, right? So the url should be with a prefixapi/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
add a comment |
1 Answer
1
active
oldest
votes
This line should be in api.php
Route::middleware('auth:api')->get('/user', function (Request $request)
return $request->user();
);
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
This line should be in api.php
Route::middleware('auth:api')->get('/user', function (Request $request)
return $request->user();
);
add a comment |
This line should be in api.php
Route::middleware('auth:api')->get('/user', function (Request $request)
return $request->user();
);
add a comment |
This line should be in api.php
Route::middleware('auth:api')->get('/user', function (Request $request)
return $request->user();
);
This line should be in api.php
Route::middleware('auth:api')->get('/user', function (Request $request)
return $request->user();
);
answered Mar 25 at 19:57
sentysenty
4,243859142
4,243859142
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
"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 prefixapi/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