From 18e05586cc8987a5c6607e7eb0851916b7c5d529 Mon Sep 17 00:00:00 2001 From: Charles Zhao Date: Tue, 12 Sep 2023 21:38:37 +0800 Subject: [PATCH] fix(console): input verification code in profile page should not crash the app (#4489) * fix(console): input verification code in profile page should not crash the app * chore: add changeset --- .changeset/mean-jeans-clap.md | 5 +++++ packages/console/src/hooks/use-redirect-uri.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/mean-jeans-clap.md diff --git a/.changeset/mean-jeans-clap.md b/.changeset/mean-jeans-clap.md new file mode 100644 index 000000000..1ab46821e --- /dev/null +++ b/.changeset/mean-jeans-clap.md @@ -0,0 +1,5 @@ +--- +"@logto/console": patch +--- + +fix the app crash when inputting verification code in Console profile page diff --git a/packages/console/src/hooks/use-redirect-uri.ts b/packages/console/src/hooks/use-redirect-uri.ts index 85129c841..82cde107d 100644 --- a/packages/console/src/hooks/use-redirect-uri.ts +++ b/packages/console/src/hooks/use-redirect-uri.ts @@ -1,5 +1,6 @@ import { ossConsolePath } from '@logto/schemas'; import { conditionalArray, joinPath } from '@silverhand/essentials'; +import { useMemo } from 'react'; import { useHref } from 'react-router-dom'; import { isCloud } from '@/consts/env'; @@ -13,8 +14,9 @@ const useRedirectUri = (flow: 'signIn' | 'signOut' = 'signIn') => { const path = useHref( joinPath(...conditionalArray(!isCloud && ossConsolePath, flow === 'signIn' ? '/callback' : '/')) ); + const url = useMemo(() => new URL(path, window.location.origin), [path]); - return new URL(path, window.location.origin); + return url; }; export default useRedirectUri;