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

DavidLoevy's avatar

POST request for Laravel API ver.7 not working on webhosting

hi friends, I have created Laravel (ver.7) app for REST API:

in "api.php" is defined route:

Route::post('post','API\RegisterController@post');

and "RegisterController.php" has following code:

public function post(Request $request)  {
        //$input = $request->all();
        return response()->json(['test' => 'TEST', 'value' => '1234']);
}

If I try this POST request on my local WAMP server via "Postman" utility:

POST  http://api/public/index.php/api/post

I get correct result:

{
    "test": "TEST",
    "value": "1234"
}

with status: 200 OK, but if I am copying the same code to webhosting and try the same POST request (via "Postman") to location on my webhosting:

POST   bigoo.eu/subdom/API/public/index.php/api/post

I get error "405 Method Not Allowed". But all other GET requests work properly on webhosting. I cannot find where problem is ... please help me. Each useful tips appreciate

0 likes
1 reply
tykus's avatar

If .../public/index.php/... are necessary in your URL, your web server has not been setup correctly, and you are probably also exposing sensitive data in your .env file.

Please or to participate in this conversation.