简体   繁体   English

Angular 5-如何使用特定标题重定向到外部URL?

[英]Angular 5 - How to redirect to an external url with specific headers?

This is what I am trying to achieve with Angular : 这就是我试图通过Angular实现的目标:

this.headers = ...;

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

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. 当我从服务器收到get请求的响应时,我想重定向到带有特定标头的外部url,以便能够在两个应用程序之间传递一些信息。

There must be a way to do this. 必须有一种方法可以做到这一点。 I know it's not possible using window.location.href . 我知道使用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. 据我了解,这是重定向,而不是请求:这意味着您无法将标头添加到重定向中。

But , what you can do, is send URL params to your second application. 但是 ,您可以做的是将URL参数发送到第二个应用程序。

In your URL, simply append 在您的网址中,只需追加

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

At the end of your URL. 在网址末尾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM