如何在用户注销时路由到另一个网站 - Angular

How to route to another website when user Logout - Angular

我正在尝试在用户注销时将页面重定向到 Google 的主页。 为此,我使用了以下函数:

$(window.location)[0].replace(this.urlLogout);

但我没有被重定向到 Google,而是在 URL 浏览器中获取了这条路线:

http://localhost:4200/www.google.com.br

有谁知道如何解决这个问题?

似乎您缺少协议部分,要么尝试从您的 API 获取它,要么您可以在客户端进行。

window.location.replace(`https://${this.urlLogout}`);

或者如果你确定你网站的协议和重定向域是一样的,你可以这样做

window.location.replace(`${window.location.protocol}//${this.urlLogout}`);

window.location.replace(this.urlLogout) 这应该有效,确保 this.urlLogout 有 http:// 或 https:// 如果没有你可以在客户端添加它或者如果你有控制在 API 那边然后

@Lokesh Daiya

这对我有用,它是 URL 前面缺少的 http:// 协议。 这就是我收到此错误的原因。

谢谢!