I wrote a method in Vue 2.0 with Vue Resource which connects to an API with Basic Authentication.
getCountries: function()
{
options = {
headers:
{
'type' : 'GET',
'Authorization' : 'Basic c3VyZWJ1ZGR5LWFwaS11c2VyOkFwaTQzMjJTdXJlYg==',
'Access-Control-Allow-Headers': 'Content-Type',
'Access-Control-Allow-Methods': 'GET',
'Access-Control-Allow-Origin' : '*',
'dataType' : "json"
}
}
this.$http.get('http://surebuddy.azurewebsites.net/Api/Products', [options])
.then((response) => {
console.log(response.body);
}, (error) => {
console.log(error);
});
}
When I run this in the browser I simply get a "403 (Forbidden)" error message in the console.
With these authorisation credentials in Postman I can perfectly connect and receive data. I have a feeling that I'm incorrectly passing the Authorization in the header.
Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" Header set Access-Control-Allow-Headers "*, Authorization"