Laravel 5 POST routes to index instead of store

后端 未结 2 528
难免孤独
难免孤独 2021-01-02 14:19

I am working on a Laravel 5 RESTful API that seems not to be routing the POST requests correctly.

This is my routes.php:

Route::group(array(\'prefix\         


        
相关标签:
2条回答
  • 2021-01-02 14:28

    The problem was caused by a trailing / being added to the URL. So, instead of using this URL:

    mydomain.com/api/v1/messages/

    I tried with this one:

    mydomain.com/api/v1/messages

    and it worked.

    I discovered it by taking a look at the server's log. That is how I discovered that POST requests to the URL messages/ were redirected.

    0 讨论(0)
  • 2021-01-02 14:44

    if you are still having this problem and the route is using FormRequest

    check if there a authorize function in it because it will redirect if it returns false

    0 讨论(0)
提交回复
热议问题