- @Injectable() export class ConstantService {
constructor(private router: Router, private _logger: Logger) { }
public WEBSERVICE_URL: string = "http://localhost:8081/abcd/";
public OAUTH2_CLIENT_USERNAME: string =
"springbootproj-trusted-client"; public OAUTH2_CLIENT_PASSWORD:
string = "secret";
public MESSAGE_ACCESSTOKEN_EXPIRED: string = "Looks like your
access token has been expired. Please login."; public
MESSAGE_INTERNAL_SERVER_ERROR: string = "Some internal server error
has occured. Please try again. If problem persists then please
contact Administrator."; public MESSAGE_NO_RECORDFOUND_ERROR:
string = "No records found.";
public handleError = function (error: Response) {
let errMsg = error.json().error || 'Server error';
this._logger.error("Error",errMsg);
// console.error("Response error: " + errMsg);
if (error.status === 0) {
alert(this.MESSAGE_ACCESSTOKEN_EXPIRED);
this.router.navigate(['/login']);
} else if (error.status === 500) {
alert(this.MESSAGE_INTERNAL_SERVER_ERROR);
}
return Observable.throw(error.json().error || 'Server error'); }.bind(this);
public extractData = function (res: Response) {
if (res.status === 204) {
alert(this.MESSAGE_NO_RECORDFOUND_ERROR);
} else {
let body: any;
if (res.text()) {
body = res.json();
}
return body || {};
} }.bind(this) }
答案 0 :(得分:0)
我得到了这个问题的答案。在使用JWT-COOKIES安全性的情况下,如果服务器和客户端位于不同的机器(域)上,我们无法将cookie存储在缓存中。您需要将它们放在单个机器上(域名)。