Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

deladels's avatar

API Routes saying 405 Method not allowed

Error says that the GET Method is not supported but the method registered is a route method. I can't seem to figure out what exactly is going on.

api.php file

Route::post('register', RegistrationController::class)->name('api.register');
Route::post('login', LoginController::class)->name('api.login');

This is the error I get in postman:

{
  "message": "The GET method is not supported for this route. Supported methods: POST.",
  "exception": "Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException",
  "file": "/Users/delaakakpo/Projects/afap-ims/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php",
  "line": 117,
  "trace": [
    {
      "file": "/Users/delaakakpo/Projects/afap-ims/vendor/laravel/framework/src/Illuminate/Routing/AbstractRouteCollection.php",
      "line": 103,
      "function": "methodNotAllowed",
      "class": "Illuminate\Routing\AbstractRouteCollection",
      "type": "->"
    },
}

Here's an image of the request in insomnia:

https://imgur.com/a/wBcZQwH

0 likes
10 replies
Sergiu17's avatar

You send a GET request to a POST route, send a POST request instead

Sergiu17's avatar

He's using Laravel as an API, so not sure if he needs a GET route to the register page

deladels's avatar

@sergiu17 it's actually a POST request I am sending. Unfortunately I can't add an image from Postman. But it's actually a POST request

trin's avatar

use imagehosting and markdown syntax for post image.

1 like
deladels's avatar

I've attached an image link to the post

Sergiu17's avatar

what is base_uri equals to?

route in api.php are prefixed with api

so, your request should to to app_url + '/api/register'

trin's avatar

can u post raw hhtp request, with headers etc?

Please or to participate in this conversation.