Axios POST requests and Ci security class |
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
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 (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. |
Welcome Guest, Not a member yet? Register Sign In |