Search code examples
phpcodeignitercodeigniter-3csrf

CSRF token error while working with REST Api in codeigniter


I'm working in codeigniter v3 and i got error when i use CSRF token while working with REST API in postman error looks like this..

enter image description here

Can anybody help me with this. Also i want to disable CSRF protection for several urls. I tried to achieve this by placing the url in

$config['csrf_exclude_uris'] = array('webservice');

but it still not working.


Solution

  • You need to specify the full uri like this:

    $config['csrf_exclude_uris'] = array(
        'webservice/addCandidate'
    );
    

    Or with regex :

    $config['csrf_exclude_uris'] = array(
        'webservice/[a-zA-Z]+'
    );