You are not logged in.

#1 2016-02-18 07:31:34

z3ntu
Member
Registered: 2016-01-02
Posts: 14

[SOLVED] AurJson issue: "No 'Access-Control-Allow-Origin' header"

When I use a $http object from AngularJS to get info about an AUR item, I get the error:

XMLHttpRequest cannot load https://aur.archlinux.org/rpc/?args%5B%5D=asdasdasd&type=info&v=5. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

Code in angularjs:

$http.get("https://aur.archlinux.org/rpc/", {params: {v: "5", type: "info", "arg[]": package_name}}).success(function (data) {

Last edited by z3ntu (2016-02-18 09:12:10)

Offline

#2 2016-02-18 09:11:49

z3ntu
Member
Registered: 2016-01-02
Posts: 14

Re: [SOLVED] AurJson issue: "No 'Access-Control-Allow-Origin' header"

It works with jsonp.

$http.jsonp("https://aur.archlinux.org/rpc/", {
                params: {
                    v: "5",
                    type: "info",
                    "arg[]": input,
                    callback: "JSON_CALLBACK"
                }
            }).success(function (data) {
                $scope.timeout = null;
                $scope.valid_package = data.resultcount != 0;
            });

Offline

Board footer

Powered by FluxBB