I have a site that I hosted in Shopify in HTTPS
, then I made a GET via Angular to a HTTP
site.
Angular
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,900" rel="stylesheet">
<style type="text/css">
div {
font-family: 'Roboto', sans-serif;
}
p, a {
font-size: 12px;
font-family: 'Roboto', sans-serif;
}
.body-text-header-large {
font-size: 1.5em;
font-weight: 300;
line-height: 2em;
color: #42baf1;
font-family: 'Roboto', sans-serif;
}
.company-name {
font-weight: 900;
font-family: 'Roboto', sans-serif;
}
</style>
<div ng-app="myApp" ng-controller="myCtrl">
<div class="container">
<span class="body-text-header-large">DISTRIBUTORS</span>
<p class="silver">Bioss Antibodies are sold worldwide. Find a distributor near you to order in your area!</p>
<div ng-repeat="obj in data" >
<div class="row">
<!-- Country -->
<div class="col-xs-4 text-center" >
<p>{{obj.country}}</p>
<img src="data:image/png;base64,{{obj.flag}}" alt="" width="30px">
</div>
<!-- Main Info -->
<div class="col-xs-4" >
<p class="company-name">{{obj.user.username}}</p>
<p>{{obj.distributor.phone_public}}</p>
<p>{{obj.user.email}}</p>
<a href="{{obj.distributor.url}}">{{obj.distributor.url}}</a></span> <span class="col span_2_of_6">
</div>
<!-- Logo -->
<div class="col-xs-4 pull-right" >
<img src="data:image/png;base64,{{obj.logo}}" alt="" width="100px">
</div>
</div>
<br><hr>
</div>
</div>
</div>
<script>
"use strict";
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get("http://d.biossusa.com/api/distributor?key=*******")
.then(function(response) {
var data = response.data;
var array = $.map(data, function(value) {
return [value];
});
console.log(typeof(array));
console.log(array.length);
console.log(array);
try {
$scope.data = array;
} catch (error) {
console.log('its not json');
}
});
});
</script>
Result locally
work perfectly fine
I kept getting
Refused to connect to 'http://d.biossusa.com/api/distributor?key=******' because it violates the following Content Security Policy directive: "connect-src 'self' https://* wss://*".
Turning my API site from HTTP into HTTPS might be a bit expensive. What is the work around for this ?
Is there another way ?
Is there any frameworks or API that help avoid this error ?