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