mercredi 13 juin 2018

Apache2 - HTTP POST request getting converted to GET

I'm developing APIs for one of my projects using "Laravel 5.6", the project is hosted on DigitalOcean. On local server the api calls work perfectly fine.

But on remote server, the POST calls gives the following error

{
"message": "",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException",
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php",
"line": 255,
"trace": [
    {
        "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php",
        "line": 242,
        "function": "methodNotAllowed",
        "class": "Illuminate\\Routing\\RouteCollection",
        "type": "->"
    },
    {
        "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php",
        "line": 176,
        "function": "getRouteForMethods",
        "class": "Illuminate\\Routing\\RouteCollection",
        "type": "->"
    },
    {
        "file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
        "line": 612,
        "function": "match",
        "class": "Illuminate\\Routing\\RouteCollection",
        "type": "->"
    }

As per the error POST Api doesn't exists, but it does. So I tried to test the theory, where I have added a GET api for the same.

Now, when I hit the POST api, it gets converted/redirected to GET.

Have seen multiple queries online but couldn't find a fix.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire