Laravel get routes work, post don't

2019-06-04 21:30发布

问题:

I just can't figure it out, why on my local environment the following routes work perfectly.... and on a Staging environment I have been provided, to test the code, it doesn't work as supposed to

Routes:

Route::controller(Controller::detect());

...

Route::get('api', array(
        'as' => 'api_index',
        'uses' => 'api@index',
));

Route::get('api/(:any)/(:any)', 'api.(:1)@(:2)');
Route::post('api/(:any)/(:any)', 'api.(:1)@(:2)');
Route::put('api/(:any)/(:any)', 'api.(:1)@(:2)');
Route::delete('api/(:any)/(:any)', 'api.(:1)@(:2)');

The problem stands at my post requests, as they just won't be found and always returning a 404 no mather the request. Example:

  • POST http://staging.test.com/api -> 404
  • POST http://staging.test.com/api/user -> 404
  • POST http://staging.test.com/api/user/session -> 404

Where all of the above tests, work in my local environment. The GET method works (the only one besides POST that I have tested)

So what am I missing?

UPDATE

Tried changing the order of the Routes::, and tried the different methods... but still the same result

回答1:

Just as @TheShiftExchange said, it seams to be the buggy Controller::detect()'s fault.

Have tried also:

Route::controller(array('api.user', 'api.device'));

But only got it to work with:

Route::controller('api.user');
Route::controller('api.device');