久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='8o9DP'><tr id='8o9DP'><dt id='8o9DP'><q id='8o9DP'><span id='8o9DP'><b id='8o9DP'><form id='8o9DP'><ins id='8o9DP'></ins><ul id='8o9DP'></ul><sub id='8o9DP'></sub></form><legend id='8o9DP'></legend><bdo id='8o9DP'><pre id='8o9DP'><center id='8o9DP'></center></pre></bdo></b><th id='8o9DP'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='8o9DP'><tfoot id='8o9DP'></tfoot><dl id='8o9DP'><fieldset id='8o9DP'></fieldset></dl></div>
<legend id='8o9DP'><style id='8o9DP'><dir id='8o9DP'><q id='8o9DP'></q></dir></style></legend>

<small id='8o9DP'></small><noframes id='8o9DP'>

          <bdo id='8o9DP'></bdo><ul id='8o9DP'></ul>
        <tfoot id='8o9DP'></tfoot>
      1. 將 X-CSRF-Token 標頭全局添加到 XMLHttpRequest() 的所有

        Adding X-CSRF-Token header globally to all instances of XMLHttpRequest();(將 X-CSRF-Token 標頭全局添加到 XMLHttpRequest() 的所有實例;)

            <small id='cgRTc'></small><noframes id='cgRTc'>

          • <i id='cgRTc'><tr id='cgRTc'><dt id='cgRTc'><q id='cgRTc'><span id='cgRTc'><b id='cgRTc'><form id='cgRTc'><ins id='cgRTc'></ins><ul id='cgRTc'></ul><sub id='cgRTc'></sub></form><legend id='cgRTc'></legend><bdo id='cgRTc'><pre id='cgRTc'><center id='cgRTc'></center></pre></bdo></b><th id='cgRTc'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cgRTc'><tfoot id='cgRTc'></tfoot><dl id='cgRTc'><fieldset id='cgRTc'></fieldset></dl></div>

                <bdo id='cgRTc'></bdo><ul id='cgRTc'></ul>
                <tfoot id='cgRTc'></tfoot>

                    <tbody id='cgRTc'></tbody>
                1. <legend id='cgRTc'><style id='cgRTc'><dir id='cgRTc'><q id='cgRTc'></q></dir></style></legend>

                2. 本文介紹了將 X-CSRF-Token 標頭全局添加到 XMLHttpRequest() 的所有實例;的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在使用第三方庫,它使用 new XMLHttpRequest 生成原始 XMLHttpRequest.

                  I am using a third party library which spawns a raw XMLHttpRequest with new XMLHttpRequest.

                  這繞過了我的 CSRF 保護并被我的 Rails 服務器擊落.

                  This bypasses my CSRF protection and gets shot down by my rails server.

                  有沒有辦法將預定義的 CSRF 令牌 ($('meta[name=csrf-token]').attr('content')) 全局添加到 的所有實例XMLHttpRequest 在實例化時?

                  Is there a way to globally add a predefined CSRF token ($('meta[name=csrf-token]').attr('content')) to ALL instances of XMLHttpRequest at instantiation time?

                  推薦答案

                  我建議攔截調用發送方法:

                  (function() {
                      var send = XMLHttpRequest.prototype.send,
                          token = $('meta[name=csrf-token]').attr('content');
                      XMLHttpRequest.prototype.send = function(data) {
                          this.setRequestHeader('X-CSRF-Token', token);
                          return send.apply(this, arguments);
                      };
                  }());
                  

                  這不會在實例化時添加標頭,而是在發送請求之前添加.您可以攔截對 new XMLHttpRequest() 的調用,但這無濟于事,因為您需要等待添加標頭直到 open 被調用.

                  This won't add the header at instantiation time, but right before the request is sent. You can intercept calls to new XMLHttpRequest() as well, but that won't be helpful as you need to wait with adding the header until open was called.

                  您可能還希望對請求的目標 URL 進行測試,以便僅在調用自己的 api 時添加標頭.不這樣做可能會在其他地方泄漏令牌,甚至可能會破壞不允許此標頭的跨域 CORS 調用.

                  You might also want to include a test for the target URL of the request, so that you only add the header when your own api is called. Not doing so might leak the token elsewhere, or might even break cross-domain CORS calls that don't allow this header.

                  這篇關于將 X-CSRF-Token 標頭全局添加到 XMLHttpRequest() 的所有實例;的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  <tfoot id='XuWWI'></tfoot>
                    <tbody id='XuWWI'></tbody>
                3. <i id='XuWWI'><tr id='XuWWI'><dt id='XuWWI'><q id='XuWWI'><span id='XuWWI'><b id='XuWWI'><form id='XuWWI'><ins id='XuWWI'></ins><ul id='XuWWI'></ul><sub id='XuWWI'></sub></form><legend id='XuWWI'></legend><bdo id='XuWWI'><pre id='XuWWI'><center id='XuWWI'></center></pre></bdo></b><th id='XuWWI'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='XuWWI'><tfoot id='XuWWI'></tfoot><dl id='XuWWI'><fieldset id='XuWWI'></fieldset></dl></div>

                      <legend id='XuWWI'><style id='XuWWI'><dir id='XuWWI'><q id='XuWWI'></q></dir></style></legend>
                      • <bdo id='XuWWI'></bdo><ul id='XuWWI'></ul>

                        <small id='XuWWI'></small><noframes id='XuWWI'>

                            主站蜘蛛池模板: 国产精品免费观看 | 国产精品乱码一区二区三区 | 欧美日韩综合一区 | 亚洲视频一区二区三区四区 | 一区二区av | 九九热精品在线视频 | 欧美极品视频在线观看 | 亚洲激情综合 | 欧美午夜影院 | 国产精品视频网 | 国产精品一区二区三区在线播放 | 人人人人干 | 国产精品精品视频一区二区三区 | 黄色三级毛片 | 韩国精品在线观看 | 国产精品毛片一区二区在线看 | 日韩成人 | 欧美成人第一页 | 中文成人在线 | 亚洲一区二区三区四区五区午夜 | 黄色一级大片在线免费看产 | 五月天婷婷狠狠 | 在线中文字幕亚洲 | 狠狠操av | 久久这里只有精品首页 | 99re在线视频 | 成人免费高清 | 性欧美hd | 国产精品明星裸体写真集 | 精品蜜桃一区二区三区 | 日日噜噜噜夜夜爽爽狠狠视频, | 午夜av一区二区 | 香蕉av免费| 欧美久久久网站 | 99精品欧美一区二区三区 | 欧美99 | 91精品国产91久久综合桃花 | 91精品久久久久久久久 | 久久美女网 | 亚洲av一级毛片 | 四虎影院免费在线 |