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

    <small id='4slKS'></small><noframes id='4slKS'>

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

    2. <tfoot id='4slKS'></tfoot>

      <legend id='4slKS'><style id='4slKS'><dir id='4slKS'><q id='4slKS'></q></dir></style></legend>

        <bdo id='4slKS'></bdo><ul id='4slKS'></ul>

      預檢中帶有 http 401 的 Ajax CORS 請求

      Ajax CORS Request with http 401 in preflight(預檢中帶有 http 401 的 Ajax CORS 請求)

      <tfoot id='tpU4s'></tfoot>

            <tbody id='tpU4s'></tbody>

          • <bdo id='tpU4s'></bdo><ul id='tpU4s'></ul>

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

              1. <legend id='tpU4s'><style id='tpU4s'><dir id='tpU4s'><q id='tpU4s'></q></dir></style></legend>
                <i id='tpU4s'><tr id='tpU4s'><dt id='tpU4s'><q id='tpU4s'><span id='tpU4s'><b id='tpU4s'><form id='tpU4s'><ins id='tpU4s'></ins><ul id='tpU4s'></ul><sub id='tpU4s'></sub></form><legend id='tpU4s'></legend><bdo id='tpU4s'><pre id='tpU4s'><center id='tpU4s'></center></pre></bdo></b><th id='tpU4s'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tpU4s'><tfoot id='tpU4s'></tfoot><dl id='tpU4s'><fieldset id='tpU4s'></fieldset></dl></div>
                本文介紹了預檢中帶有 http 401 的 Ajax CORS 請求的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我現在掙扎了好幾個小時.我想向另一個域發出一個簡單的 ajax 請求,但總是得到 http 401 錯誤:

                I am struggling for hours now. I want to make a simple ajax request to another domain, but get http 401 Error all the time:

                jQuery(document).ready(function($){
                  var challengeid = $('#codepressHook').data('challengeid');
                  var clicked = false;
                  $('#codepressHook').click(function(){
                    if(!clicked){
                      $.ajax({
                        url: "https://dev.radbonus.com/admin/affiliate-connections/retrieveSingle/"+challengeid+".json",
                        method: "GET",
                        dataType: "json",
                        jsonp: false,
                        contentType: "application/json",
                        xhrFields: {
                          withCredentials: true
                        },
                        beforeSend: function(xhr){
                          xhr.setRequestHeader("Authorization", "Basic "+ btoa(username+":"+password));
                        },
                        success: function(data){
                          $('#codepressHock').html(data.data.code);
                        },
                        error: function(error){
                          alert(error);
                        }
                      });
                    }
                  });
                });
                

                我在服務器端設置了所有相關的 CORS 標頭.這是網絡流量:

                I set all relevant CORS headers on the serverside. Here is the network traffic:

                Request URL:https://dev.radbonus.com/admin/affiliate-connections/retrieveSingle/45.json
                Request Method:OPTIONS
                Status Code:401 Unauthorized
                Remote Address:185.102.94.230:443
                Referrer Policy:no-referrer-when-downgrade
                
                Response Headers
                view source
                Access-Control-Allow-Credentials:true
                Access-Control-Allow-Headers:Content-Type, X-Requested-With, Authorization, Origin
                Access-Control-Allow-Methods:POST, GET, PUT, DELETE, OPTIONS
                Access-Control-Allow-Origin:http://radbonus.com
                Access-Control-Max-Age:31536000
                Content-Length:463
                Content-Type:text/html; charset=iso-8859-1
                Date:Sat, 24 Jun 2017 11:25:33 GMT
                Server:Apache/2.4.18 (Ubuntu)
                WWW-Authenticate:Basic realm="Admin"
                
                Request Headers
                view source
                Accept:*/*
                Accept-Encoding:gzip, deflate, sdch, br
                Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
                Access-Control-Request-Headers:authorization,content-type
                Access-Control-Request-Method:GET
                Connection:keep-alive
                Host:dev.radbonus.com
                Origin:http://radbonus.com
                Referer:http://radbonus.com/plugintest/
                User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
                

                我知道有很多關于這個主題的帖子,但似乎我缺少一些簡單的東西.誰能幫幫我?

                I know that there are a lot of posts on this topic, but it seems I'm missing something simple. Could anyone help me?

                推薦答案

                UPDATE 看來我說的不對.Authorization 標頭永遠不會為 OPTIONS 請求發送.請參閱 sideshowbarker 的評論 - 您需要確保您的服務器不會以 401 響應 OPTIONS 請求.

                UPDATE Looks like I was not right. Authorization header is never sent for OPTIONS request. Please see comment by sideshowbarker - you need to make sure that your server doesn't respond with 401 to OPTIONS request.

                我不知道你的服務器是用什么語言編寫的,但是你以錯誤的方式實現了授權 - OPTIONS 方法應該從 auth 中排除.另請參閱此處 - OPTIONS 請求身份驗證

                I don't know what language is your server written in, but you implemented authorization in the wrong way - OPTIONS method should be excluded from auth. Also see here - OPTIONS request authentication

                以下是過時的答案:

                您的服務器端需要對該請求進行 HTTP 基本身份驗證.而且您不提供憑據.401錯誤與CORS無關;這只是意味著服務器選擇不授權您的請求,因為您沒有提供身份驗證憑據.

                Your serverside requires HTTP Basic authentication for this request. And you don't provide credentials. 401 error has nothing to do with CORS; it just means that the server chose to not authorize your request because you didn't provide auth credentials.

                如果您嘗試打開此網址(如 https://dev.radbonus.com/admin/affiliate-connections/retrieveSingle/1.json) 直接在瀏覽器中,您將被要求輸入登錄名和密碼,這是瀏覽器使用 WWW-Authenticate 處理 401 錯誤的方式 標題.

                If you try to open this url (like https://dev.radbonus.com/admin/affiliate-connections/retrieveSingle/1.json) directly in browser, you will be asked to enter login&password, which is how the browser handles 401 error with WWW-Authenticate header.

                請注意 Authorization 標頭實際上并未包含在您的請求中.所以不要使用 beforeSend 鉤子,你應該直接在你的調用中包含標題:

                Please notice that Authorization header is actually not included with your request. So instead of using beforeSend hook, you should probably just include header directly in your call:

                headers: {
                    'Authorization': 'Basic ' + btoa(username+':'+password),
                },
                

                并確保 Authorization 標頭出現在您的請求中.

                And make sure that Authorization header presents in your request.

                這篇關于預檢中帶有 http 401 的 Ajax CORS 請求的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 部分內容)
                  <bdo id='Nd4fz'></bdo><ul id='Nd4fz'></ul>

                    <legend id='Nd4fz'><style id='Nd4fz'><dir id='Nd4fz'><q id='Nd4fz'></q></dir></style></legend>
                          <tbody id='Nd4fz'></tbody>

                        <tfoot id='Nd4fz'></tfoot>

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

                      • <i id='Nd4fz'><tr id='Nd4fz'><dt id='Nd4fz'><q id='Nd4fz'><span id='Nd4fz'><b id='Nd4fz'><form id='Nd4fz'><ins id='Nd4fz'></ins><ul id='Nd4fz'></ul><sub id='Nd4fz'></sub></form><legend id='Nd4fz'></legend><bdo id='Nd4fz'><pre id='Nd4fz'><center id='Nd4fz'></center></pre></bdo></b><th id='Nd4fz'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Nd4fz'><tfoot id='Nd4fz'></tfoot><dl id='Nd4fz'><fieldset id='Nd4fz'></fieldset></dl></div>
                        1. 主站蜘蛛池模板: 黄色片中文字幕 | 成人在线免费 | 久久国产影院 | 亚洲一区二区三区免费 | 免费av观看| 久久午夜影院 | www.国产视频 | 亚洲成人免费av | 视频一区二区三区在线观看 | 欧美黄色免费网站 | 中文字幕高清在线 | 成人免费网址 | 91久久国产综合久久 | 九九热只有精品 | 四虎影视av | 国产成人在线观看免费网站 | 欧美在线观看一区二区 | 亚洲一级二级 | 日韩高清在线播放 | 亚洲性视频 | 日韩看片 | 五月天综合网 | 精品国产一区二区三 | 97av视频| 中文字幕免费在线看线人动作大片 | 精品99视频| 日韩精品一级 | 91中文在线 | 精品久久影院 | 超碰在线成人 | 亚洲成人一区 | 精品视频一区二区三区 | 亚洲一级片 | 国产不卡视频在线观看 | 日韩精品免费一区二区夜夜嗨 | 91精品国产99久久久久久红楼 | 中文字幕欧美激情 | 久婷婷 | 日韩精品片 | 91久久精品视频 | 红桃av在线|