Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

CSRF vuejs-axios not working

$
0
0
Hi,
Spending hours to post some vuejs - axios data to my codeigniter.


PHP Code:
axios({
method'post',
url'http://puppyplaza.dev/api/saveprofile',
data: {
    
csrf_token'b2897db3f48b2c08c7313f280b290eb3',
    
emailthis.profile.email
}
}) 


In my config the token name is "csrf_token".  csrf_regenerate is FALSE just to simplify the problem.
http://puppyplaza.dev/api/save profile is a for now a simple controller to display the result (on my localhost)

PHP Code:
    public function saveprofile()
    {
        
$data = array('data'=> 'data to send back to browser');
        
$this->load->helper('security');
        
//$this->input->post('csrf_token'); 
        //$csrf =  $this->security->get_csrf_hash();
        
$this->output
        
->set_content_type('application/json')
        ->
set_output(json_encode(array('data' => $data'csrf' => $csrf)));

    } 

With Jquery it works Smile
data: {'csrf_token':'b2897db3f48b2c08c7313f280b290eb3'},

With axios it wont!

[Image: error.png]


Please, please anyone!?

Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>