https://supabase.com/ logo
#help
Title
# help
m

Mike_

06/09/2022, 8:19 PM
In development, when I try to sign in using magic link, it always redirects me to the production app and authenticates there instead. Is there some way to use magic-link sign-in in development? So far, the best (hacky) workaround I've found is manually pasting the production auth token into my localhost's localStorage to authenticate...
n

Needle

06/09/2022, 8:19 PM
Hello @Mike_! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
g

garyaustin

06/09/2022, 8:53 PM
You might look at this. Seems you can add localhost to the redirect urls list and use redirectTo option in the signIn. Don't think that would work for the magic link button in the auth window on the dashboard. I've not tried this. https://github.com/supabase/supabase/discussions/600
b

burggraf

06/09/2022, 10:45 PM
Just add the redirectTo parameter.
Let me dig up my example.
Copy code
const { user, session, error } = await supabase.auth.signIn({
      email: email
    }, {
      redirectTo: window.location.origin
    });
    return { user, session, error };
Just make sure to whitelist your localhost url in the Supabase dashboard. Now you can send magic links in production and in local development and you'll get redirected to the correct place.
m

Mike_

06/10/2022, 1:52 PM
Ahhh brilliant! I'll give this another try. I tried using the redirectTo param yesterday but used it incorrectly:
Copy code
js
// wrong
supabase.auth.signIn({
    email: email,
    redirectTo: window.location.origin
})
b

burggraf

06/10/2022, 1:54 PM
Another important note: as of about a week ago, you can use wildcards in your whitelisted URLs in the dashboard, so you can say: http://localhost:3000/** (using glob syntax) to allow any URL that starts with http://localhost:3000. Or just a single * to denote a wildcard, so if you use http://localhost:3000/* that would allow http://localhost:3000/abc but not http://localhost:3000/abc/123.
m

Mike_

06/10/2022, 1:55 PM
Oooh this will save me some pain... I had
http://localhost:3000/*
set up instead of the double
Thanks for the heads up
Works like a charm 🙏
n

Needle

06/10/2022, 2:13 PM
Thread was archived by @Mike_. Anyone can send a message to unarchive it.