Angular 5 - 如何使用特定标头重定向到外部URL? [英] Angular 5 - How to redirect to an external url with specific headers?

查看:160
本文介绍了Angular 5 - 如何使用特定标头重定向到外部URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我想用Angular实现的目标:

This is what I am trying to achieve with Angular :

this.headers = ...;

this.http.get(`${urlApi}`).subscribe(data => {
    // go to url with specific headers
}, err => {
    console.log(err);
});

当我从服务器获得get请求的响应时,我想重定向到外部URL使用特定标题,以便能够在两个应用程序之间传递一些信息。

When I get the response of a get request from my server, I want to redirect to an external url with specific headers, to be able communicate some information between two apps.

必须有办法做到这一点。我知道使用 window.location.href 是不可能的。

There must be a way to do this. I know it's not possible using window.location.href.

推荐答案

根据我的了解,这是一个重定向,而不是一个请求:这意味着您无法向重定向添加标头。

From what I have learnt, this is a redirection, not a request : this means you can't add headers to your redirect.

但是,您可以做的是将URL参数发送到您的第二个应用程序。

But, what you can do, is send URL params to your second application.

在您的网址中,只需追加

In your URL, simply append

?param1=value1&param2=value2&param3=value3 /// etc.

在您的网址末尾。

这篇关于Angular 5 - 如何使用特定标头重定向到外部URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆