Magic Link Redirects, Local Development, and Docker
I know there have been other post on this topic but I am still having some issues getting magic link auth redirects to work in my local docker development instance.
Problem: Magic Link redirects and auth flow is broken in my docker development. Links are sent, and appear in InBucket, but upon clicking the link, the user is redirected to the url
http://127.0.0.1:54321/auth/v1/verify?token=pkce_....&type=magiclink&redirect_to=http://127.0.0.1:3000/auth/confirm
, and upon landing on the page, the user is not authed. I do see the authenticated user in supabase's auth
and my custom profiles
(setup via a function and trigger), but the user session is null
. In addition to this, the Supbase UI via docker does not have the options to easily edit Redirect URLs, email templates, etc.
My Email Template (prod):
SignIn function:
I also saw a post that mentioned being able to set the site URL in the supbase/config.toml
could help
site_url = "http://localhost:3000"
And for additional context, here is my app/api/auth/confirm/route.ts
Conclusion: I am still unsure how to approach using magic link logins in docker vs just localhost:3000. Any help or feedback would be appreciated.4 Replies
In addition to this, here is my `/app/api/auth/confirm/route.ts
I am new to docker development and I think my core issue is understanding the redirects and endpoints.
Note: I thought 127.0.0.1 was the same as localhost:3000, so maybe the cause is something unrelated to magic link email templates and directs?
You can refer to this example repo https://github.com/silentworks/supabase-by-example/tree/main/nextjs
This helped me fix the issue with redirects in Docker.
Thank you @inder !
I added the following to
supbase/config.toml
and then in the email template and functions:
---browser sees 127.0.0.1 and localhost as separate urls. So if auth cookie is set on 127.0.0.1, it won't be seen on localhost