Laravel get routes work, post don't

懵懂的女人 提交于 2019-12-08 06:51:10

问题


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');


来源:https://stackoverflow.com/questions/14810009/laravel-get-routes-work-post-dont

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!