Hi so I am currently working on authentication thr...
# help
w
Hi so I am currently working on authentication through Magic Link with Supabase and something weird is happening. The project is built with Next JS This is the login function
Copy code
javascript
async function signIn() {
    const { error, data } = await supabase.auth.signIn(
      {
        email,
      },
      {
        redirectTo: "http://localhost:3000/verify",
      }
    );
    if (error) {
      console.log({ error });
    } else {
      setSubmitted(true);
    }
}
The email is sent out successfully but I have a problem with the redirect link, somehow supabase is adding a
#
to the url, so am getting
http://localhost:3000/verify#access_token=<ACCESS_TOKEN>&expires_in=3600&refresh_token=<REFRESH_TOKEN>&token_type=bearer&type=magiclink
instead of
http://localhost:3000/verify?access_token=<ACCESS_TOKEN>&expires_in=3600&refresh_token=<REFRESH_TOKEN>&token_type=bearer&type=magiclink
s
That is its intended behaviour, what issue are you having? also on redirect supabase-js normally strips the # part of the url before the redirect happens
Are you using the latest version of the library?
w
Its not stripping on my end, that's my supabase version
s
I'm using that version and it strips on mine, I wonder what could be different in your app
w
I also don't know,
Is there like some config am missing out on
Copy code
javascript
import { createClient } from '@supabase/supabase-js'

const supabaseUrl: any = process.env.NEXT_PUBLIC_SUPABASE_URL
const supabaseAnonKey: any = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY

export const supabase = createClient(supabaseUrl, supabaseAnonKey)
s
No that's all correct
w
I have tried everything,
Adding the
/verify
url to additional redirect urls,
Didn't help
Modified
redirectTo
value to
/verify?success=yes&
but I still got
/verify?success=yes#access_token=...
p
have you tried nextjs's router, and pushing (Router.push) to '/verify' upon signon?
w
How can I do that @User
Like when they click submit, I immediately take them to
/verify
, then how am I going to get the
access_token
sent to the email