Open patrioticcow opened 6 years ago
Hi, if you want to set headers, i think you should do like that :
this.$http.get('http://localhost:8080/api/v1/users',
{
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'POST, GET, PUT, OPTIONS, DELETE',
'Access-Control-Allow-Headers': 'Access-Control-Allow-Methods, Access-Control-Allow-Origin, Origin, Accept, Content-Type',
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
).then(function (response) {
// Success
}, function (response) {
// Error
})
Same error and work fine with XMLHttpRequest, last solution no work
To fix this, you need to return some of the headers mentioned above from your server.
'Access-Control-Allow-Origin': '*'
I cant change 'Access-Control-Allow-Origin': '*'
as you suggested because I am using apis like github oauth. I am not building an API I am using it
I an trying to to a simple get request, and I get an
Access-Control-Allow-Origin
errorIf I do a regular
xhr
request, I don't get the error and all is goodIf I try to do a
jsonp
request instead, I getUncaught SyntaxError: Unexpected token :
, basically failing to parse the json response.Any ideas?