0

My Error message is:
Font from origin 'http://MyNewDomain:8088' has been blocked from loading by Cross-Origin Resource Sharing policy: The 'Access-Control-Allow-Origin' header has a value 'http://MyServerIP' that is not equal to the supplied origin. Origin.
My Angular Code is below:

$scope.test = function() {
        var data = JSON.stringify({"alias": "spielt-heute-robbie-williams-in-zug-2016-12-07-16048973-50723287"});
        console.log(data);
        var inserturl = nodeurl+"/home/getarticleDetails";
        $http({
            method: "POST",
            // cache: true,
            url: inserturl,
            headers: {
                // "Content-Type": "application/json", 
                'Content-Type': 'application/x-www-form-urlencoded'
            },

            data: {body: $.param(data) }

        }).success(function(response, status, headers, config) {
              console.log(response);
        }).error(function(data, status,headers, config) {
              console.log(data);

        });
    };

    $scope.test();

And Also Below is My Node JS Controller code:

  var express = require("express");
    var router = express.Router();
    var data={};
    var model=require('../models/Homemodel');
    router.post('/getarticleDetails', function(req, res) {
         data=model.fetch_ad.getarticleDetails(req.body,function(callback){

            res.header('Access-Control-Allow-Origin', "*");     // TODO - Make this more secure!!
            res.header('Access-Control-Allow-Methods', 'POST,GET,PUT,OPTIONS');
            res.header('Access-Control-Allow-Headers', 'Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept'); 


            res.send(callback);

         });
        });
module.exports = router;
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445

0 Answers0