Reputation: 2419
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.
Upvotes: 0
Views: 965
Reputation: 146269
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;
}
}
Upvotes: 2