Nick Schnee
Nick Schnee

Reputation: 11

Supabase: Confirm-Signup-Email always redirects to Root

I'm building a course on Supabase for my students. In the course they work in different chapters (nested folders) in a GitHub repo which they can upload on a server or test locally.

There will be a chapter (folder) for magiclink-signup and one for password-signup.

The problem is, the URL in the confirm-signup-email always redirects to the root (e.g. https://studentserver.com) of the server instead of https://studentserver.ch/03\_supabase\_authentication/1\_magiclink.html. On the root, authentication obviously fails.

I defined the redirect URL in the Supabase dashboard to my nested folder: https://studentserver.ch/03\_supabase\_authentication/1\_magiclink.html

And I also set the redirect-url programmatically to window.location.href:

const supa = supabase.createClient(supabaseUrl, supabaseKey, {  
 auth: {  
 redirectTo: window.location.href,
},  
});

What am I doing wrong?

Upvotes: 0

Views: 619

Answers (1)

dshukertjr
dshukertjr

Reputation: 18680

What you have set as the redirect URL and what is passed to the redirectTo option in your sign up code has to match exactly. No extra slashes or anything are allowed. If you use window.location.href, it might include some slashes or extra query parameters. Because of this, it's probably better to hard code it.

Also, using underscores in your URL could cause some unwanted issues. I would rename your html file with hyphens instead of underscores.

https://studiohawk.com.au/blog/dash-or-underscore-in-url-heres-how-its-affecting-your-seo/#:~:text=Underscores%20can't%20be%20used,underscore%20character%20isn't%20permitted.&text=Google's%20web%20crawlers%20don't,your%20file%20names%20for%20you.

Upvotes: 0

Related Questions