문제

I am doing a post from an external server to my Laravel app and it is throwing this exception on app/filters/policy.php: Illuminate\Session\TokenMismatchException.

This is my app/filters/policy.php:

Route::filter('csrf', function()
{
    $token = Request::ajax() ? Request::header('X-CSRF-Token') : Input::get('_token');

    if (Session::token() != $token)
    {
        throw new Illuminate\Session\TokenMismatchException;
    }
});

And this is my app/route.php:

Route::any('webservice', ['uses' => 'WebserverController@postWebservice']);

I think it is because the CSRF filter is applied to all routes, but I don't know how to disable it to /webservice.

I'd appreciate any help.

도움이 되었습니까?

해결책

Maybe you may try something like this:

if(Request::url() != 'http://example.com//webservice') {
    $token = Request::ajax() ? Request::header('X-CSRF-Token') : Input::get('_token')
    if (Session::token() != $token) {
        throw new Illuminate\Session\TokenMismatchException;
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top