I am sending from my server (SpringBoot) a cumstom header ->>
SpringBoot:
response.addHeader("headerToken", "valueToken");
response.addHeader("Access-Control-Allow-Origin","*");
response.addHeader("Access-Control-Allow-Methods","GET");
response.setHeader("Access-Control-Expose-Headers","Custom-Header");
return new ModelAndView("redirect:" + url);
My return is "http://...path...AngularJS...etc"
My flow doesn't AngularJS call SpringBoot and return AngularJS, so, I can't do ->
$http.get('Springboot').
success(function(data, status, headers, config) {
...
})
.error(function(data, status, headers, config) {
...
});
How my flow doesn't AngularJS->Springboot->AngularJS I can't get headers in my http.succes... from AngularJS.
Then I thinked get headers in my controller with JS ->
angular.module('don').controller('Dona', ['$rootScope', '$scope', '$http', '$cookies', '$routeParams', '$window', '$location', function ($rootScope, $scope, $http, $cookies, $routeParams, $window, $location) {
var self = this;
var req = new XMLHttpRequest();
req.open('GET', document.location, false);
req.send(null);
var headers = req.getAllResponseHeaders().toLowerCase();
console.log(headers);
console.log("---");
req .addEventListener("readystatechange", function () {
if (this.readyState == this.HEADERS_RECEIVED)
console.log(this.getAllResponseHeaders())
});
console.log("***");
// Load get data
...etc
}]);
(this.readyState is null)
The result is ->
https://i.stack.imgur.com/mDpGS.png
I need 10 repu for show imgYou can see that I added -> response.setHeader("Access-Control-Expose-Headers","Custom-Header");
...
how I can read the my valueToken ?
See this img pls->
https://i.stack.imgur.com/LmfXK.png
(I need 10 repu for show img)