I'm developing a REST service with Laravel to consume it from a mobile app. It works properly on local, but not on hosting. After several tries, I developed a basic example to test the POST method, but it returns the same error.
api.php file
Route::post('/test', 'testController@test') ;
testController.php file
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class testController extends Controller
{
//
public function test(Request $request)
{
return response()->json(['mensaje' => 'POST access successful']);
}
}
POST request is always returning the same error, and I am using POST on petition: 405 Method Not Allowed. The GET method is not supported for this route. Supported methods: POST.
I have investigated this topic and I have read it could be due CORS. So, I have installed spatie/laravel-cors with its default config, but POSTMAN is still showing the same error. Some help, please?
SOLVED: Thanks all! Definitely, it was not a CORS problem. My hosting server makes a redirect by default, losing POST parameters in the way.