How to implement CSRFGuard in ExtJs AjaxRequest?

流过昼夜 提交于 2019-12-11 03:36:09

问题


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


回答1:


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




回答2:


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;
});


来源:https://stackoverflow.com/questions/11554220/how-to-implement-csrfguard-in-extjs-ajaxrequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!