2016-04-18 12 views
0

現在、私はJHipster 3(JHipster 2から移行中)に取り組んでいます。私のモジュールの中にはJSONデータを取得するためにRESFTfulからリクエストされるものがあります。CORSリクエスト中のJHipster 3エラー

ここJHipster 2のサンプルコード: - >(作業)

'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; 
        } 
       } 
      }); 
     }); 

そして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; 
        } 
       } 
      }); 
     } })(); 

そして、私はエラーだ:で

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. 

をapplication.ymlもすでにCORSに対応しています

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 

この問題を解決するためのアドバイスはありますか?

答えて

0

allowed-originを指定する必要があります(例:http://localhost:9000)。allow-credentials:trueと組み合わせてワイルドカード*にすることはできません。

+0

まだ動作していません.. Jhipster 2と同じコードが動作していますが、Jhipster 3では使用できません。 – ag3ng

関連する問題