1

I want to call my functions from android side.

now, I want to send post values from android side.

How can I disable csrf token for some functions ?

because without it I got error message .

like this:

Route::post('mobile/android/getlastnews','NewsController@getLastNews');
S.M_Emamian
  • 17,005
  • 37
  • 135
  • 254
  • 2
    Possible duplicate of [In Laravel5, How to disable VerifycsrfToken middleware for specific route?](http://stackoverflow.com/questions/31223189/in-laravel5-how-to-disable-verifycsrftoken-middleware-for-specific-route) – Imran Aug 08 '16 at 08:06
  • Possible duplicate of [How to disable CSRF Token in Laravel and why we have to disable it?](http://stackoverflow.com/questions/37806762/how-to-disable-csrf-token-in-laravel-and-why-we-have-to-disable-it) – Imesha Sudasingha Aug 08 '16 at 08:33

2 Answers2

6

Open app/Http/Middleware/VerifyCsrfToken.php and in the protected $except = []; array add your URL that you want to be skipped for CSRF validation.

S.M_Emamian
  • 17,005
  • 37
  • 135
  • 254
thefallen
  • 9,496
  • 2
  • 34
  • 49
6

For Laravel 5.2, inside app/Http/Middleware/VerifyCsrfToken.php you just need to add it to the $except array.

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'mobile/android/getlastnews'
    ];
}

If you wanted to allow all routes for mobile/ you can do the following

protected $except = [
    'mobile/*'
];
Leon Vismer
  • 4,925
  • 1
  • 20
  • 22