私は今何時間も苦労しています。Ajax CORSプリフライトでhttp 401でリクエスト
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ヘッダーを設定:私は別のドメインへの単純なAJAX要求を行うが、HTTP 401エラーのすべての時間を取得したいです。ここでは、ネットワークトラフィックがある:
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
私はこのトピックに関する記事がたくさんあることを知っているが、私は、単純な何かが欠けてるようです。誰か助けてくれますか?
https://dev.radbonus.comのサーバーのバックエンドは、200または204でOPTIONS要求に応答するように設定する必要があります少なくとも、http://radbonus.comからのリクエストと、少なくとも "/admin/affiliate-connections/retrieveSingle/45.json"というパスのリクエストについては、成功メッセージです。 https://stackoverflow.com/posts/44735921/editを使用して質問を更新/編集して、https://dev.radbonus.comのバックエンドで実行されているソフトウェアの詳細を追加します、ここに誰もあなたをもっと助けることができるだろう – sideshowbarker
私は参照してください。あなたはhaproxyでそれをする方法を知っていますか?なぜなら、私はウェブでそのようなものを見つけることができないからです。 –