重定向后本地存储丢失

时间:2018-07-26 12:59:43

标签: angular https

我有一个在https上运行的角度应用程序。此应用重定向到外部网站进行登录,并提供该外部网站的返回URL,以便外部系统在成功通过身份验证后可以再次调用我的应用。

不幸的是,当外部系统再次调用我的返回URL时,我的本地存储不再存在。

此行为似乎仅在我将系统移至云端和https上之后才发生。只要我在本地运行所有内容,并且没有使用https就能正常运行。

有什么想法为什么会发生以及如何解决?

添加执行重定向的代码段:

@Injectable()
export class CustomHttp extends Http {
    constructor(backend: ConnectionBackend, defaultOptions: RequestOptions){ 
    super(backend, defaultOptions);
    }
    private handleError(error: any) {
    if (error.status === 401) {
       window.location.href= "https://externalsystem/services/oauth2/authorize?response_type=code&client_id=xyz&redirect_uri=https://myapp.eu-west-2.elb.amazonaws.com/login/SFDC&state="+window.location.href;
    }

    return Observable.throw(error._body);
    }
}

如您所见,如果后端返回身份验证错误,我将重定向到外部系统。我给外部系统打电话,提供系统的返回URL。

调用返回网址时,本地/会话存储区消失了。

Rgds 迈克尔

0 个答案:

没有答案