1
我所有的DELETE和PUT請求都被阻止(405)。我曾嘗試在之前和之後的過濾器把標題:Laravel 4 DELETE/PUT被阻止
App::before(function($request)
{
header('Access-Control-Allow-Origin', '*');
header('Allow', 'GET, POST, OPTIONS, PUT, DELETE');
header('Access-Control-Allow-Headers', 'Origin, Content-Type, Accept, Authorization, X-Request-With');
header('Access-Control-Allow-Credentials', 'true');
});
App::after(function($request, $response)
{
$response->headers->set('Access-Control-Allow-Origin', '*');
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
$response->headers->set('Access-Control-Allow-Headers', 'Origin, Content-Type, Accept, Authorization, X-Requested-With');
$response->headers->set('Access-Control-Allow-Credentials', 'true');
$response->headers->set('Access-Control-Max-Age','86400');
return $response;
});
我已經嘗試添加的.htaccess規則,允許他們在laravel公用文件夾:
<Limit GET POST PUT DELETE HEAD OPTIONS>
Order allow,deny
# You might want something a little more secure here, this is a dev setup
Allow from all
</Limit>
<LimitExcept POST PUT DELETE HEAD OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
我已經在使用構造嘗試資源控制器,並且似乎沒有任何事實上允許任何請求類型我在這裏很快就沒有想法了,我正在使用apache和kendo UI來製作AJAX請求。我的路線如下所示:
// PUBLIC
Route::group(array('prefix' => 'api/v1'), function()
{
Route::post('login', array('uses'=>'[email protected]'));
Route::get('status', array('uses'=>'[email protected]'));
});
// PROTECTED BY SENTRY
Route::group(array('prefix' => 'api/v1', 'before' => 'auth'), function()
{
Route::get('logout', array('uses'=>'[email protected]'));
Route::get('users/whoami', array('uses'=>'[email protected]'));
Route::resource('users', 'UsersController');
Route::resource('programs', 'ProgramsController'); // THIS ROUTE KEEPS 405'ING ME
});
過濾器文件中沒有什麼太花哨的東西,只是使用Sentry2進行用戶管理。任何幫助將不勝感激!