You'll need to send provide your angular app from the server with an object that you will modify in the angular code
For instance, in your server code inject an extra parameter, which will be modified in the angular app if you need a redirection.
let respData = {redirectUrl: ''};
//....
extraProviders: [
{
provide: 'httpResponseData',
useValue: respData,
}
In the angular application, inject that extra parameter in the constructor of the component/service where you want to specify the redirect url
constructor(@Inject(PLATFORM_ID) private platformId: Object, @Optional() @Inject('httpResponseData') private httpResponseData: any)
{
//...
}
When you want to redirect, use the new parameter instead of the window object
redirect(url: string)
{
if(isPlatformBrowser(this.platformId))
{
window.location.href = url;
}
else
{
this.httpResponseData.redirectUrl = url;
}
}
Finally, in your web server, check the value of the respData.redirectUrl property and redirect if the url is set