$.ajax({
type: "get",
url: "http://myserver.com",
beforeSend: function (xhr, data) {
xhr.setRequestHeader("Authorization", "xxxx");
}
});
當我檢查這種呼叫中螢火我看到選項,同時也看不出在請求頭授權代碼的樣本代碼。 CORS頭已添加到服務器端。
response.addHeader("Access-Control-Allow-Headers", "origin, content-type, accept, x-requested-with");
response.addHeader("Access-Control-Max-Age", "60");
response.addHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
response.addHeader("Access-Control-Allow-Origin", "*");
response.addHeader("Access-Control-Allow-Credentials", "true");
想法是使用純粹的jQuery,如果它可以執行這樣的查詢。
你在服務器端使用什麼? PHP? – RononDex
@RononDex Java Spring,從PostMan嘗試過,其他工具可以作爲魅力。 – vaske
你爲什麼要發送一個GET請求與身體? –