2016-04-18 6 views
0

Derzeit arbeite ich an JHipster 3 (Migration von JHipster 2). Einige meiner Module werden von RESFTful angefordert, um JSON-Daten zu erhalten.JHipster 3 Fehler während der CORS Anfrage

Hier ist der Beispielcode in JHipster 2: -> (Arbeits)

'use strict'; 

angular.module('newsletterApp') 
    .factory('UserBirthday', function ($resource) { 
     return $resource('http://localhost:8081/BirthDay/Rest/WebService/GetFeeds', {}, { 
       'query': {method: 'GET', isArray: true}, 
       'get': { 
        method: 'GET', 
        isArray: true, 
        transformResponse: function (data) { 
         data = angular.fromJson(data); 
         return data; 
        } 
       } 
      }); 
     }); 

Und für Jhipster 3:

(function(){ 
     'use strict'; 

     angular 
      .module('newsletterApp') 
      .factory('EmployeeBirthday', EmployeeBirthday); 

     EmployeeBirthday.$inject = ['$resource']; 

     function EmployeeBirthday($resource){ 
      return $resource('http://localhost:8081/BirthDay/Rest/WebService/GetFeeds', {}, { 
       'query': {method: 'GET', isArray: true}, 
       'get': { 
        method: 'GET', 
        isArray: true, 
        transformResponse: function (data) { 
         data = angular.fromJson(data); 
         return data; 
        } 
       } 
      }); 
     } })(); 

Und ich habe Fehler:

XMLHttpRequest cannot load http://localhost:8081/BirthDay/Rest/WebService/GetFeeds. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. 

In application.yml ist auch bereits für CORS

aktiviert 0
cors: #By default CORS are not enabled. Uncomment to enable. 
     allowed-origins: "*" 
     allowed-methods: GET, PUT, POST, DELETE, OPTIONS 
     allowed-headers: "*" 
     exposed-headers: 
     allow-credentials: true 
     max-age: 1800 

Irgendwelche Ratschläge, um dieses Problem zu lösen?

Antwort

0

Der erlaubte-Ursprung muss angegeben werden (z. B. http://localhost:9000) und kann nicht Wildcard * in Kombination mit allow-credentials: true sein.

+0

Immer noch nicht funktioniert .. Derselbe Code funktioniert für Jhipster 2 .. Aber nicht für Jhipster 3 .. – ag3ng

Verwandte Themen