Access-Control-Allow-Origin
Hey, While writing a JS app, I noticed that Access-Control-Allow-Origin is not set on api.peeringdb.com. I also see that there's an open issue for this ( https://github.com/peeringdb/peeringdb/issues/78 ). I was wondering what would be the best way to do this - should I sync and host my own copy of the API, or are you OK with having random calls to the API from webapps? /Ruairi
This is a JSONP issue (well worth a search on stackoverflow). Once you master that there are no XSS errors. I also means you don't need the server to enabled "allow origin". I had some code that works as-is. var url = peeringdb_api_url + '/' + $scope.getJSONParam1 + '/' + $scope.getJSONParam2; url = url + '?callback=JSON_CALLBACK'; console.log('url = "' + url + '"'); $http.jsonp(url, config) .then(function successCallback(response) { console.log('successCallback() called'); $scope.getCallJSONResult = logResult("GET SUCCESS", response.data, response.status, response.statusText, response.headers, response.config); }, function errorCallback(response) { console.log('errorCallback() called'); $scope.getCallJSONResult = logResult("GET ERROR", response.data, response.status, response.statusText, response.headers, response.config); }); }; This is in Angular - but that's a whole other conversation. Try that. Martin On Wed, Jan 11, 2017 at 11:00 AM, Ruairi Carroll <ruairi.carroll@gmail.com> wrote:
Hey,
While writing a JS app, I noticed that Access-Control-Allow-Origin is not set on api.peeringdb.com. I also see that there's an open issue for this ( https://github.com/peeringdb/peeringdb/issues/78 ).
I was wondering what would be the best way to do this - should I sync and host my own copy of the API, or are you OK with having random calls to the API from webapps?
/Ruairi
_______________________________________________ Pdb-tech mailing list Pdb-tech@lists.peeringdb.com http://lists.peeringdb.com/cgi-bin/mailman/listinfo/pdb-tech
Hey Martin, Thanks for bringing this to my attention - useful ! However my original question still stands: Should we be hitting api.peeringdb.com directly, or hosting our own installs for any apps we develop? Cheers /Ruairi On 11 January 2017 at 20:16, Martin J. Levy <mahtin@mahtin.com> wrote:
This is a JSONP issue (well worth a search on stackoverflow). Once you master that there are no XSS errors. I also means you don't need the server to enabled "allow origin". I had some code that works as-is.
var url = peeringdb_api_url + '/' + $scope.getJSONParam1 + '/' + $scope.getJSONParam2; url = url + '?callback=JSON_CALLBACK'; console.log('url = "' + url + '"'); $http.jsonp(url, config) .then(function successCallback(response) { console.log('successCallback() called'); $scope.getCallJSONResult = logResult("GET SUCCESS", response.data, response.status, response.statusText, response.headers, response.config); }, function errorCallback(response) { console.log('errorCallback() called'); $scope.getCallJSONResult = logResult("GET ERROR", response.data, response.status, response.statusText, response.headers, response.config); }); };
This is in Angular - but that's a whole other conversation.
Try that.
Martin
On Wed, Jan 11, 2017 at 11:00 AM, Ruairi Carroll <ruairi.carroll@gmail.com
wrote:
Hey,
While writing a JS app, I noticed that Access-Control-Allow-Origin is not set on api.peeringdb.com. I also see that there's an open issue for this ( https://github.com/peeringdb/peeringdb/issues/78 ).
I was wondering what would be the best way to do this - should I sync and host my own copy of the API, or are you OK with having random calls to the API from webapps?
/Ruairi
_______________________________________________ Pdb-tech mailing list Pdb-tech@lists.peeringdb.com http://lists.peeringdb.com/cgi-bin/mailman/listinfo/pdb-tech
On 12.01.2017 15:41, Ruairi Carroll wrote:
However my original question still stands: Should we be hitting api.peeringdb.com <http://api.peeringdb.com> directly, or hosting our own installs for any apps we develop?
Whichever works best for you, Ruair. An own installation might give better performance if you need that. Arnold -- Arnold Nipper Chief Technology Evangelist and Co-Founder DE-CIX Management GmbH | Lindleystrasse 12 | 60314 Frankfurt am Main | Germany | www.de-cix.net | Phone +49 69 1730902 22 | Mobile +49 172 2650958 | Fax +49 69 4056 2716 | arnold.nipper@de-cix.net | Geschaeftsfuehrer Harald A. Summa | Registergericht AG Koeln HRB 51135
participants (3)
-
Arnold Nipper -
Martin J. Levy -
Ruairi Carroll