[英]How to redirect to http://localhost:4200/shops/shop1/dashboard after auth0 login in Angular
登錄后Auth0不會重定向到http://localhost:4200/shops/shop1/dashboard
。 登錄后只會回調root http://localhost:4200。
Auth0官方文檔說:
用戶通過身份驗證后,我們只會回調這些 URL 中的任何一個。 您可以通過以逗號分隔它們來指定多個有效的 URL(通常用於處理不同的環境,如 QA 或測試)。 請務必指定協議 (https://),否則在某些情況下回調可能會失敗。 除了本機客戶端的自定義 URI 方案外,所有回調都應使用協議 https://。 您可以在這些 URL 中使用組織 URL 參數。
Auth0 帳戶中允許的回調 URL:
http://localhost:4200/pages/welcome, http://localhost:4200/shops/shop1/dashboard,
http://localhost:4200
允許 Web 來源:
http://localhost:4200, http://localhost:4200/shops/shop1/dashboard
允許來源 (CORS)
http://localhost:4200, http://localhost:4200/shops/shop1/dashboard
使用 auth 服務登錄內置的 Auth0
loginWithRedirect(): void {
// Call this to redirect the user to the login page
this.auth.loginWithRedirect();
}
感謝您提前抽出時間:)
我得到它作為:
<button
*ngIf="(auth.isAuthenticated$ | async) === false"
(click)="loginWithRedirect({
appState: { target: '/shops/shop1/dashboard' }
})">
Log in
</button>
並且工作正常:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.