S
Supabase8mo ago
W0idz

Password reset

Im trying to setup an password reset to my site, but when i did it sent me to localhost:3000, but i found this site, but whatever i put here it doesnt work, currently it displays what shows in the second image. im wondering, how does this all work, and how can i get it to work correctly
No description
No description
83 Replies
j4
j48mo ago
The site url is your app's main site. You'll wanna move the full resetpassword url to the redirect section.
W0idz
W0idzOP8mo ago
so do i put the netlify url there now and the subpage in the Redirect URLs section?
W0idz
W0idzOP8mo ago
so like this?
No description
j4
j48mo ago
I've never tried with netlify, but theoretically yes. If you're just developing locally right now, then it would need to be http://localhost:port
W0idz
W0idzOP8mo ago
i use bolt to publish the site, and it auto publishes to netlify so for testing yes, but later on we will host it out self prob but when i click the reset link it just takes me here
W0idz
W0idzOP8mo ago
No description
W0idz
W0idzOP8mo ago
No description
garyaustin
garyaustin8mo ago
You have to set a redirectTO option in your reset call.
garyaustin
garyaustin8mo ago
Otherwise it always goes to siteUrl.
W0idz
W0idzOP8mo ago
im very new to this, so i dont know how to do that exactly So if the link is https://gorgeous-cheesecake-6f3397.netlify.app/ and the sub page is update-password how would that be setup in there
garyaustin
garyaustin8mo ago
What call are you using for auth... Each has a redirectTo type of option that you pass and that has to match exactly one of your redirectTo URLs in the settings. Look at the reference for JS client and your auth call.
W0idz
W0idzOP8mo ago
im making the full site via bolt so im not 100% sure
garyaustin
garyaustin8mo ago
Not much we can do to help if you don't have the call.
W0idz
W0idzOP8mo ago
I mean its surely somewhere, i just dont know where exactly
No description
W0idz
W0idzOP8mo ago
but give me a sec to find it
garyaustin
garyaustin8mo ago
https://supabase.com/docs/reference/javascript/auth-resetpasswordforemail For instance is one kind of reset password call.
JavaScript: Send a password reset request | Supabase Docs
Supabase API reference for JavaScript: Send a password reset request
garyaustin
garyaustin8mo ago
That section of the docs all all the auth calls and shows the redirect option for each.
W0idz
W0idzOP8mo ago
should be this one
const { error } = await supabase.auth.resetPasswordForEmail(email, {
redirectTo: `${window.location.origin}/update-password`,
});
const { error } = await supabase.auth.resetPasswordForEmail(email, {
redirectTo: `${window.location.origin}/update-password`,
});
silentworks
silentworks8mo ago
This all depends on if bolt creates single page application (SPA) or server-side rendering (SSR) apps.
W0idz
W0idzOP8mo ago
How would i know which it did?
silentworks
silentworks8mo ago
Isn't bolt some sort of ai thing? if it is then just ask it.
W0idz
W0idzOP8mo ago
can try
W0idz
W0idzOP8mo ago
No description
W0idz
W0idzOP8mo ago
thats its answer
silentworks
silentworks8mo ago
Yeah so the code you shared above should work
W0idz
W0idzOP8mo ago
its currently set up like this
No description
silentworks
silentworks8mo ago
With the redirectTo set on the .resetPasswordForEmail?
W0idz
W0idzOP8mo ago
this is the full code of that page called UpdatePassword.tsx
W0idz
W0idzOP8mo ago
bruh it didnt fit
silentworks
silentworks8mo ago
Please answer the question I asked above your message
W0idz
W0idzOP8mo ago
this is how its set so it would be
const { error } = await supabase.auth.resetPasswordForEmail(email, {
redirectTo: 'https://gorgeous-cheesecake-6f3397.netlify.app/update-password',
});
const { error } = await supabase.auth.resetPasswordForEmail(email, {
redirectTo: 'https://gorgeous-cheesecake-6f3397.netlify.app/update-password',
});
according to bolt
W0idz
W0idzOP8mo ago
No description
silentworks
silentworks8mo ago
Ok so it has the netlify url harcoded in there and thats the same URL you have in your dashboard
W0idz
W0idzOP8mo ago
yep
No description
garyaustin
garyaustin8mo ago
No they have two slashes Well you did.
silentworks
silentworks8mo ago
Have you tested it since you removed the extra slash in the Redirect URLs?
silentworks
silentworks8mo ago
Can you share how your supabase.ts file looks inside of your lib directory. You can retract the anon key before sharing it if you wish.
W0idz
W0idzOP8mo ago
import { createClient } from '@supabase/supabase-js'; const supabaseUrl = import.meta.env.VITE_SUPABASE_URL; const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY; export const supabase = createClient(supabaseUrl, supabaseAnonKey);
silentworks
silentworks8mo ago
Maybe your email client has link pre-fetching and is visiting the link causing it to expire before you click the actual link.
W0idz
W0idzOP8mo ago
how could i fix that xd
W0idz
W0idzOP8mo ago
i use gmail so thats prob the case
garyaustin
garyaustin8mo ago
I hate to suggest something that could destroy where bolt has your app, but OTP signup instead of redirects works in alot more environments. Plus it is odd that you just got that and not before... Maybe you are running the same email link? You can only click it once.
silentworks
silentworks8mo ago
I don't have this issue with gmail. Maybe it's something else.
silentworks
silentworks8mo ago
If the project isn't a sensitive one you can probably share the code in a repo and tomorrow I can take a look at it. Otherwise I have a React SPA which works with all these flows that you can test and also look at the code to see how it works https://github.com/silentworks/supabase-by-example/tree/main/react
GitHub
supabase-by-example/react at main · silentworks/supabase-by-example
Contribute to silentworks/supabase-by-example development by creating an account on GitHub.
W0idz
W0idzOP8mo ago
sure thing, i think we actually have it setup already to upload to github https://github.com/Ryzz3nn/BlitzForge its prob not up to date though i think i need to manually push it
garyaustin
garyaustin8mo ago
Take your time... silentworks is way past bedtime where he is.
silentworks
silentworks8mo ago
Yep and that's my cue to go bed
W0idz
W0idzOP8mo ago
GitHub
GitHub - Ryzz3nn/BlitzBoost: Created with StackBlitz ⚡️
Created with StackBlitz ⚡️. Contribute to Ryzz3nn/BlitzBoost development by creating an account on GitHub.
W0idz
W0idzOP8mo ago
that one is from now
silentworks
silentworks8mo ago
I'm testing this out now
silentworks
silentworks8mo ago
App code work fine for me when testing it with the Supabase CLI, here is a screen recording of it working. I'm going to deploy it to Netlify and see if I get a different result.
silentworks
silentworks8mo ago
I just tested this on Netlify and its working there too. Now I'm not sure what you have wrong in your Supabase dashboard because the application code itself works as expected.
garyaustin
garyaustin8mo ago
Did you click the link in the email more than once as you were debugging? It can only be used once.
silentworks
silentworks8mo ago
My URL config looks like this too and my .resetPasswordForEmail code in the ResetPassword.tsx looks like this
const { error } = await supabase.auth.resetPasswordForEmail(email, {
redirectTo: 'https://delicate-marigold-bb264c.netlify.app/update-password',
});
const { error } = await supabase.auth.resetPasswordForEmail(email, {
redirectTo: 'https://delicate-marigold-bb264c.netlify.app/update-password',
});
No description
silentworks
silentworks8mo ago
@W0idz I just tested it on your domain and it works there for me too. So something off about your email client or you have something installed on your computer that is scanning links in your emails.
W0idz
W0idzOP8mo ago
Hmm weird, i opened the mail via gmail in my browser so it’s all in the browser
silentworks
silentworks8mo ago
And you click the link or are you copy and pasting it?
W0idz
W0idzOP8mo ago
Just clicking the link
silentworks
silentworks8mo ago
Which browser are you using and do you have any browser extensions installed?
W0idz
W0idzOP8mo ago
Brave. Yes but none that should interact in that way, like a volume addon that can adjust volume etc
silentworks
silentworks8mo ago
And the link you got in your email had http://localhost:3000 in it instead of https://gorgeous-cheesecake-6f3397.netlify.app/update-password? Because the link I got in the email from your domain is https://ezsybaiksalcmhcoqmbn.supabase.co/auth/v1/verify?token=5c1b7334b187cb781b34aa1286e7e32ecc592e5bca59a121815c6eb4&type=recovery&redirect_to=https://gorgeous-cheesecake-6f3397.netlify.app/update-password which as you can see has the https://gorgeous-cheesecake-6f3397.netlify.app/update-password in it.
W0idz
W0idzOP8mo ago
The second one forwarding to localhost, I can double check once I’m on pc in like 30 minutes this is the link i get https://ezsybaiksalcmhcoqmbn.supabase.co/auth/v1/verify?token=10c19e3b88bcb1fe6dda3a7a14dde34cc10cd32793a2eeaf93896538&type=recovery&redirect_to=https://gorgeous-cheesecake-6f3397.netlify.app/update-password
silentworks
silentworks8mo ago
And what happened when you clicked on that link?
W0idz
W0idzOP8mo ago
No description
W0idz
W0idzOP8mo ago
it actually took me to the right site now but i copied it if i click it directly in the mail it expires though
garyaustin
garyaustin8mo ago
Likely your email provider is testing the link then when you click it. If you look in the Dashboard auth logs you will likely see two requests with the 2nd failing.
W0idz
W0idzOP8mo ago
Gmail most likely checks everything yea But can’t you change the behavior of the link
garyaustin
garyaustin8mo ago
Are you using their browser client? If so likely. It may be an option. That is why one of the first links given was how to deal with that or use OTP 6 digit token. https://supabase.com/docs/guides/auth/auth-email-templates#limitations
W0idz
W0idzOP8mo ago
Im using brave and opening the mail via the browser
garyaustin
garyaustin8mo ago
With gmail's client? It really does not matter that much though as you won't control your users email setup.
W0idz
W0idzOP8mo ago
Fair, but yea Gmail is mostly doing something But it’s when I click the link in the mail
garyaustin
garyaustin8mo ago
Scanning can occur when the link is clicked, when the mail is opened or even on the server before it gets to your mailbox depending on the setup for various mail services/clients.
W0idz
W0idzOP8mo ago
So in this case it likely check it when I click it
garyaustin
garyaustin8mo ago
Sounds like you are getting scanned when you click it. If you can copy and it is still good.
garyaustin
garyaustin8mo ago
No description
garyaustin
garyaustin8mo ago
Click-time link protections in third-party email clients - Gmail Help
Because links to malicious websites can be sent in emails, Google adds link protection for all official Gmail clients (web, Android, and iPhone & iPad). Some of these protections are now available
W0idz
W0idzOP8mo ago
I’ve never run into this issue before though on any other site
garyaustin
garyaustin8mo ago
The Supabase link I gave shows ways to handle. Some in your app, and alternative of OTP.
silentworks
silentworks8mo ago
Not sure why your gmail would be doing that whilst mine doesn't. I haven't changed any settings in my gmail at all. Can you test this in a different browser? I'm somehow feeling like Brave is the one pre-scanning the link when you click it.

Did you find this page helpful?