我越來越想做利用愛可信在reactjs應用的ajax
調用錯誤的mirriad。我有一個api
生活在一個子域,並從主域進行調用。Reactjs Ajax請求跨源處理
的.htaccess:在reactjs(使用愛可信)
Header add Access-Control-Allow-Origin: "*"
Header add Access-Control-Allow-Credentials: "true"
Header add Access-Control-Allow-Methods: "GET,HEAD,OPTIONS,POST,PUT"
Header add Access-Control-Allow-Headers: "Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers"
阿賈克斯頭:
var options = {
method: 'GET',
url: 'http://admin.mysite.com/menus/5',
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET,HEAD,OPTIONS,POST,PUT',
'Access-Control-Allow-Headers': 'Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers'
}
}
我試圖更改每個這些卻得到不同的錯誤。如果我有Header add Access-Control-Allow-Origin: "*"
它抱怨雙重起源。如果我刪除它,我收到一個關於Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response
的錯誤其他更改已回覆Access-Control-Allow-Headers is not allowed by Access-Control-Allow-Headers in preflight response
我使用wordpress作爲無頭CMS並利用restful api來提取我需要的數據。如果我刪除了所有這一切,我可以get
我的數據不錯,但我不能post
無固定跨域問題,我已經注意到了。
嘗試修改您的標頭「Access-Control-Allow-Origin」:'*',''Access-Control-Allow-Origin':'http:// admin.mysite.com',' –