I made a website on a local computer, after transferring it to the server and https API requests stopped working
routes/api.php
Route::post('/shop/search', SearchController::class);
call this url:
https://server.example/api/shop/search
Unit tests work for post requests , but requests from Postman
or other utilities display an error { "message": "The GET method is not supported for route api/shop/search. Supported methods: POST." }
If I change in api.php
to get
method – it works.
Tried various solutions that I found on this topic, but still post requests are not processed over HTTPS.
2
Answers
It is normal to get that error, when you make a call like this
https://server.example/api/shop/search
you are sending aGET
request, and you define this route withPOST
request inside your API routes.Define the same route again but with
GET
method, it is normal to define the same route with different methods and each method is handled by different function inside your controller.In Postman, did you use the POST method or the GET method? If you used GET, that might be the error, because the route expects a POST method. Try changing the method in Postman, as shown in the image.
Postman screen