0
我的工作應用程序前端爲vuejs
,後端爲go
。我正在將最終功能添加到身份驗證過程中,並且遇到錯誤。添加vue http標頭時出錯
當我嘗試添加任何http標頭到vuejs
請求時,我收到一個錯誤。
這是我加入到vue component
:
http: {
headers: {
Authorization: 'Bearer 123'
}
}
而且我得到一個preflight
錯誤:
XMLHttpRequest cannot load http://localhost:8000/api/investments?limit=6. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
現在我知道這通常是一個服務器端的問題,但我我正在添加響應標題resp.Header().Set("Access-Control-Allow-Origin", "*")
。 cors
。如果我刪除vue object
中的http屬性,一切正常。它的漂亮bizzare我甚至嘗試用go
處理OPTIONS
請求,但我的api處理程序甚至沒有被擊中。
隨時接受你自己的答案。 – holys
@holys我得等2天 – Rodrigo