Welcome Guest, Not a member yet? Register   Sign In
Axios POST requests and Ci security class
#1

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
Reply
#2

See this:
https://github.com/axios/axios/issues/1498

and search on Google for "axios php $_POST"
Reply
#3

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
Reply
#4

(12-18-2018, 08:29 AM)skunkbad Wrote: See this:
https://github.com/axios/axios/issues/1498

and search on Google for "axios php $_POST"

(12-18-2018, 10:19 AM)qury Wrote: 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

Thank you.
I'll use formData then.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB