How to implement CSRFGuard in ExtJs AjaxRequest?

2019-07-20 05:50发布

I'm using ExtJs for UI and am doubtful of using CSRFGuard in AjaxRequest of extjs. I'm currently appending the CSRFName and value to the URL of ajax and it is working perfectly fine.

Is there any way that the token name and value could be added as header of Ajax so that it need not be written for each and every AjaxRequest.

Seeking early response. Thanks

2条回答
Deceive 欺骗
2楼-- · 2019-07-20 06:06

Here is the another solution. It adds to every request the csrf token.

Ext.Ajax.on('beforerequest', function(conn, options) {
    options.params._token = Laravel.csrfToken;
});
查看更多
再贱就再见
3楼-- · 2019-07-20 06:25

You could put it in http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Ajax-event-beforerequest

and that would apply to every AJAX request

查看更多
登录 后发表回答