···47474848export async function login(handle: string) {
4949 const c = await getClient()
5050+5151+ // Find the redirect URI that matches the current origin
5252+ // This handles the case where the list has a trailing slash but window.location.origin does not
5353+ const currentOrigin = window.location.origin
5454+ const redirectUri = clientMetadata.redirect_uris?.find(uri =>
5555+ uri.startsWith(currentOrigin) || (uri.endsWith('/') && uri.slice(0, -1) === currentOrigin)
5656+ )
5757+5058 return await c.signIn(handle, {
5159 state: undefined,
5260 prompt: 'login',
6161+ redirect_uri: redirectUri as any, // Explicitly pass the matching URI, cast to any to avoid strict type issues
5362 })
5463}
5564
+2-2
src/components/LoginForm.tsx
···1414 try {
1515 await login(handle)
1616 // The user will be redirected, so we don't need to do anything else on success
1717- } catch (err) {
1717+ } catch (err: any) {
1818 console.error(err)
1919- setError('Failed to initiate login. Please check the handle.')
1919+ setError(err?.message || 'Failed to initiate login. Please check the handle.')
2020 setLoading(false)
2121 }
2222 }