Search code examples
fluttersupabasesupabase-jssupabase-flutter

Problems in Callback URLs when using Supabase Flutter and JavaScript SDK


I am currently developing an application that consists of two codebases: one for the web using Angular and the other for the mobile version using Flutter.

The challenge I am facing is related to setting the Site URL. When I set it to 'io.appname://appname.com/auth/verify', the mobile app is redirected correctly, but the web version encounters issues. Conversely, if I change the Site URL to 'http://localhost:4200/auth/verify', the mobile version experiences difficulties while the web version functions properly.

I have attempted various solutions, such as adding Redirect URLs and using a list of Site URLs separated by commas, but none of them have resolved the problem. When I tried using a list, only the first URL was recognized (e.g., 'http://localhost:4200/auth/verify,io.appname://io.appname/auth/verify'), which worked for the web but caused issues for the mobile version.

As a workaround, I created a separate instance for the web version connected to a different project. However, this solution led to the challenge of managing two separate databases, which is not an ideal long-term solution.

I tried adding redirectTo: but this also doesn't work, mobile:

Flutter

await Supabase.instance.client.auth.signInWithOAuth(
    Provider.google,
    redirectTo: 'io.appname://appname.com/auth/verify',
  );

Web(Angular)

await Supabase.connection.auth.signInWithOAuth({
    'google',
    options: {
      redirectTo: 'http://localhost:4200/auth/verify',
    },
  })

I would greatly appreciate any assistance or guidance you can provide to help me address this issue effectively.

Thank you for your support.

As a workaround, I created a separate instance for the web version connected to a different project. However, this solution led to the challenge of managing two separate databases, which is not an ideal long-term solution.


Solution

  • You just need to have both of the redirect URLs set as Redirect URLs in your Supabase dashboard.

    supabase dashboard