supabase-community / auth-ui

Pre-built Auth UI for React
https://supabase.com/docs/guides/auth/auth-helpers/auth-ui
MIT License
487 stars 121 forks source link

`redirectTo` is not working #76

Closed renardeinside closed 1 year ago

renardeinside commented 1 year ago

Bug report

Describe the bug

I'm trying to setup an auth with Supabase and supabase auth. Unfortunately the redirectTo argument seems either ignored or works not as expected.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. create a new app with nextjs + react + supabase-auth-ui-react.
  2. use the following code
import { Auth, ThemeSupa } from '@supabase/auth-ui-react';

export default function JoinPage() {
    const session = useSession()
    const supabase = useSupabaseClient()

    <Auth
                    supabaseClient={supabase}
                    providers={["github"]}
                    theme="evenDarker"
                    redirectTo='/me'
                />
}
  1. go to browser and try to auth with any method.

With email, it remains the same. With github, it adds a # to the end of the URL, but none of this makes a proper redirect.

Expected behavior

Redirect happens.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

Additional context

Add any other context about the problem here.

BeardedBry commented 1 year ago

I'm having the same issue

0x111 commented 1 year ago

Possible duplicate of https://github.com/supabase/auth-ui/issues/72

marianocodes commented 1 year ago

I downgraded to @0.2.1 and still doesn't work

As workaround, I used a useEffect to watch the session changes to do the redirect

  useEffect(() => {
    if (session) {
      route.push("/admin");
    }
  }, [session]);
Boluwatife2904 commented 1 year ago

Hey @renardeinside I think the redirectTo expects the full URL to redirect to which should include the Site URL in your supabase dashboard. So for example, if your site url on supabase is 'http://localhost:5173', your redirectTo should be something like 'http://localhost:5173/me' for it to work.

If your redirectTo prop is a different domain like 'http://localhost:3000/me', it would redirect to the Site URL which you setup on your supabase dashboard.