go - Golang, cors and angularjs - header missing -
i'm using rs/cors in go api allow angularjs app make direct requests. i've added following code configure cors:
crs := cors.new(cors.options{allowcredentials: true}) n.use(crs) //negroni include
but i'm getting no 'access-control-allow-origin' header present on requested resource message in browser when make request.
my request looks this:
var req = { method: 'post', url: endpoint + version + method, headers: { 'authorization': 'basic ' + btoa(':' + appid) }, data: params } $http(req). success(function(data, status, headers, config) { callback(null, data); }). error(function(data, status, headers, config) { callback(data); });
how can round this?
fixed it! noticed few different headers being sent request , had explicitly allow of them.
allowedheaders: []string{"accept", "authorization", "content-type"}
i hope helps someone.
Comments
Post a Comment