CORS, domain.com'dan bir.domain.com adresine POST isteğinde bulunmaya çalışıyorum.CORS ve Access-Control-Allow-Başlıkları nasıl çalışır?
Request URL: https://a.domain.com/some/route
Request Method:OPTIONS
Status Code:200 OK
SEÇENEKLER TALEBİ:
Access-Control-Request-Headers:origin, content-type, accept
Access-Control-Request-Method:POST
Host:a.domain.com
Origin:http://domain.com:3000
Referer:http://domain.com:3000/home
SEÇENEKLER TEPKİ
Benim javascript .OPTIONS rota şöyle çağrıldığını görebilirsiniz İlk başta bu
$('#fileupload').fileupload({
xhrFields: {
withCredentials: true
},
dataType: 'json',
url: $('#fileupload').data('path'),
singleFileUploads: true,
add: function(e, data){
data.submit();
}
});
benziyor
Access-Control-Allow-Credentials:true
Access-Control-Allow-Methods:POST
Access-Control-Allow-Origin:http://domain.com:3000
Connection:keep-alive
Content-Length:0
Content-Type:text/html;charset=utf-8
Bu istek, belirtilen 200 ile geri geliyor. Benim sunucuda, ben POST
yöntemi ile aynı güzergahı var ve bu ben OPTIONS
Request URL:https://a.domain.com/some/route
SONRASI TALEP
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryjwr5Pk7WBcfzMdbO
Origin:http://domain.com:3000
Referer:http://domain.com:3000/home
ve iptal olur POST
isteği sonrasında karşılığında elde ne olduğunu/başarısız olur.
Sorum şu: POST denetleyicisinde erişim denetimi izin verilen kaynağa sahip olmam gerekir mi?
Ben çerez bir istekte kez üzerinden gönderilen var ve şimdi gönderiliyor değil bu alan adını .domain.com
sahiptir yetkilendirme için bir çerez var. Bunun neden olabileceği hakkında bir fikrin var mı?
protokol ihmal edilebilir eklemek için PHP kullanıyorsanız? veya hem http hem de https ile bir tane ekleyebilir misiniz? – Michael