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 0cors: #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?
Immer noch nicht funktioniert .. Derselbe Code funktioniert für Jhipster 2 .. Aber nicht für Jhipster 3 .. – ag3ng