问题
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);
});
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.
There must be a way to do this. I know it's not possible using window.location.href.
回答1:
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.
In your URL, simply append
?param1=value1¶m2=value2¶m3=value3 /// etc.
At the end of your URL.
来源:https://stackoverflow.com/questions/47882425/angular-5-how-to-redirect-to-an-external-url-with-specific-headers