久久久久久久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>

      預(yù)檢中帶有 http 401 的 Ajax CORS 請(qǐng)求

      Ajax CORS Request with http 401 in preflight(預(yù)檢中帶有 http 401 的 Ajax CORS 請(qǐng)求)

      <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>
                本文介紹了預(yù)檢中帶有 http 401 的 Ajax CORS 請(qǐng)求的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

                我現(xiàn)在掙扎了好幾個(gè)小時(shí).我想向另一個(gè)域發(fā)出一個(gè)簡(jiǎn)單的 ajax 請(qǐng)求,但總是得到 http 401 錯(cuò)誤:

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

                我在服務(wù)器端設(shè)置了所有相關(guān)的 CORS 標(biāo)頭.這是網(wǎng)絡(luò)流量:

                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
                

                我知道有很多關(guān)于這個(gè)主題的帖子,但似乎我缺少一些簡(jiǎn)單的東西.誰(shuí)能幫幫我?

                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 看來(lái)我說(shuō)的不對(duì).Authorization 標(biāo)頭永遠(yuǎn)不會(huì)為 OPTIONS 請(qǐng)求發(fā)送.請(qǐng)參閱 sideshowbarker 的評(píng)論 - 您需要確保您的服務(wù)器不會(huì)以 401 響應(yīng) OPTIONS 請(qǐng)求.

                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.

                我不知道你的服務(wù)器是用什么語(yǔ)言編寫的,但是你以錯(cuò)誤的方式實(shí)現(xiàn)了授權(quán) - OPTIONS 方法應(yīng)該從 auth 中排除.另請(qǐng)參閱此處 - OPTIONS 請(qǐng)求身份驗(yàn)證

                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

                以下是過(guò)時(shí)的答案:

                您的服務(wù)器端需要對(duì)該請(qǐng)求進(jìn)行 HTTP 基本身份驗(yàn)證.而且您不提供憑據(jù).401錯(cuò)誤與CORS無(wú)關(guān);這只是意味著服務(wù)器選擇不授權(quán)您的請(qǐng)求,因?yàn)槟鷽](méi)有提供身份驗(yàn)證憑據(jù).

                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.

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

                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.

                請(qǐng)注意 Authorization 標(biāo)頭實(shí)際上并未包含在您的請(qǐng)求中.所以不要使用 beforeSend 鉤子,你應(yīng)該直接在你的調(diào)用中包含標(biāo)題:

                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 標(biāo)頭出現(xiàn)在您的請(qǐng)求中.

                And make sure that Authorization header presents in your request.

                這篇關(guān)于預(yù)檢中帶有 http 401 的 Ajax CORS 請(qǐng)求的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 ajax 調(diào)用完成)
                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 無(wú)法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)分
                Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (301 302))
                NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                  <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. 主站蜘蛛池模板: 国产一区二区三区久久久久久久久 | 91九色视频| 久久视频精品 | 日本欧美在线观看视频 | 一区二区视频在线 | 毛片入口 | 亚洲福利在线观看 | 欧美一区二区三区在线 | 亚洲欧美激情国产综合久久久 | 宅男伊人 | 皇色视频在线 | 天堂资源最新在线 | 欧美视频第三页 | 中文字幕亚洲区 | 国产一区二 | 婷婷开心激情综合五月天 | 一区二区三区久久久 | 精品久久久久一区二区国产 | 国产91丝袜在线熟 | 在线播放亚洲 | 欧美成人免费在线 | 一区二区三区精品在线视频 | 特黄特色大片免费视频观看 | 成人片免费看 | 黄a在线观看 | 欧美亚洲在线视频 | 国产精品美女久久久 | 久久久青草婷婷精品综合日韩 | 精品久久99 | 91精品一区 | 一区欧美 | 欧美精品video | 日本精品一区二区三区在线观看视频 | 亚洲www啪成人一区二区麻豆 | 日韩av成人在线 | 超黄视频网站 | 日本午夜在线视频 | 免费观看一级毛片 | 精品日韩在线观看 | av免费入口| 日韩成人一区二区 |