Welcome Guest, Not a member yet? Register   Sign In
CSRF vuejs-axios not working
#1

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!?
Reply


Messages In This Thread
CSRF vuejs-axios not working - by ponzo - 10-11-2017, 08:34 AM
RE: CSRF vuejs-axios not working - by ponzo - 10-12-2017, 02:50 AM
RE: CSRF vuejs-axios not working - by Paradinight - 10-12-2017, 08:04 PM
RE: CSRF vuejs-axios not working - by bartMommens - 10-22-2019, 02:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB