javascript - AngularJS: No "Access-Control-Allow-Origin" header is present on the requested resource -


i'm writting webapp , i'm using angularjs. in app have created file called script.js , report code:

var modulo = angular.module('progetto', ['ngroute']);      // configure our routes     modulo.config(function ($routeprovider, $httpprovider) {         $routeprovider              // route home page             .when('/', {                 templateurl: 'listafilm.html',                 controller: 'listacontroller'             })              // route description page             .when('/:phonename', {                 templateurl: 'description.html',                 controller: 'descriptioncontroller'             });               $httpprovider.defaults.headers.common['access-control-allow-origin'] = '*';      });       modulo.controller('listacontroller', function ($scope, $http) {         $http.get('https://api.getevents.co/event?&lat=41.904196&lng=12.465974').success(function (data) {             $scope.names = data;             }).             error(function (data, status) {                 $scope.names = "request failed";             });     }); 

with code call api following restful principles. when run code have problem:

xmlhttprequest cannot load https://api.getevents.co no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:8383' therefore not allowed access.

reading on web understood have problem called cors...i have tried several solutions proposed didn't resolve problem.
how can fix problem?
what's code must add fix it?

this server side issue. don't need add headers in angular cors. need add header on server side:

access-control-allow-headers: content-type access-control-allow-methods: get, post, options access-control-allow-origin: * 

first 2 answers here: how enable cors in angularjs


Popular posts from this blog