如何使用angular 5在CROS域浏览器中设置cookie?

时间:2018-06-08 15:48:30

标签: angular angular5 setcookie

我在登录后在响应标头中获得了setCookie。我调用身份验证的域(https://dev.services/acs)和主机URL(https://paging-dev.services/page)是不同的。我想知道如何在angular5中在CROS域中设置cookie。

这是我用于登录的http帖子

login(username: string, password: string, url: string) {
        let login = { "username": username, "password": password };
        const httpOptions = {
            headers: new HttpHeaders({ 'Content-Type': 'application/json' })
        };
        return this.http.post<any>('https://dev.services/acs/v1/applications/ACOPORTAL/login',
            { username: username, password: password`enter code here` }, httpOptions)

            .map(user => {
                // login successful if there's a jwt token in the response
                if (user && user.token) {
                    user = { user, timestamp: 1 };
                    // store user details and jwt token in local storage to keep user logged in between page refreshes
                    localStorage.setItem('loginUser', JSON.stringify(user));
                }
                return user;
            });
    }

0 个答案:

没有答案