Axios POST requests and Ci security class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Axios POST requests and Ci security class (/showthread.php?tid=72428) |
Axios POST requests and Ci security class - enelson - 12-18-2018 Ha anybody experience wtith using axios with CI? Axios POST requests are received via PHP's input stream, not in the usual POST array. As such, the regular method for CSRF prevention here do not work. The only workaround is to add my URL endpoint to $config['csrf_exclude_uris'] array. If I have lots of endpoints I wish to call client-side via axios, that would become a large array. I there anywhere to have CI's security class recognise the CSRF name and hash pair, when received via input stream RE: Axios POST requests and Ci security class - skunkbad - 12-18-2018 See this: https://github.com/axios/axios/issues/1498 and search on Google for "axios php $_POST" RE: Axios POST requests and Ci security class - qury - 12-18-2018 Hi instead of sending "raw" json data, send formData I had the same problem initially. var formdata = new formData (); formdata.append('key','value'); then send formdata with axios you will be able to access $_POST['key'] from php as usual RE: Axios POST requests and Ci security class - enelson - 12-21-2018 (12-18-2018, 08:29 AM)skunkbad Wrote: See this: (12-18-2018, 10:19 AM)qury Wrote: Hi Thank you. I'll use formData then. |