Search code examples
laravellaravel-5.3

MethodNotAllowedHttpException in Laravel while API writing


I am developing APIs using Laravel and I am new to it. I am using following method as route for my api but facing error.

Route in api.php:

Route::post('user/register','UserController@Register')->middleware('auth:api');

Error:

MethodNotAllowedHttpException

Is there any setting or something else which I have missed.


Solution

  • You should add /api in your url when you trying to access api routes, so it should look like this 127.0.0.1:8000/api/user/register