Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel RESTful returning 301 state

Mates, I'm developing a Backbone/Laravel application. When I try to send a POST request to a certain resource, it returns me 301 status with no response, regardless that on the controller i'm printing a 'hello world', to check if it's getting to that point.

Here's some code...

public function store()
    {
        //
        return 'hello world';
    }

This is the routes.php

Route::group(array('before' => 'auth'), function()
{
    Route::get('/', 'SitesController@index');
    Route::resource('rooms', 'RoomsController');

});

So, when I make a POST request to

rooms

With some info to save, it gives me back 301 status with no response at all.

Any idea what am I doing wrong?

Thanks in advance!

like image 866
Pablo Avatar asked Oct 25 '14 00:10

Pablo


2 Answers

Solved!

On backbone collection configuration, I had url parameter with '/' at the end.

rooms/

Deleted that slash and now it works fine. Hope someone find's this helpful

like image 147
Pablo Avatar answered Oct 01 '22 04:10

Pablo


(Adding this answer in case anyone has the same issue as me)

In my case I had a resource videos which gave the exact same problem. The reason was that I also had a directory on the server /videos/ (with files in it) which the server tried to point me to before it let Laravel direct it to the controller.

like image 38
Niels Avatar answered Oct 01 '22 06:10

Niels