triggerdotdev / docker

Docker templates for self-hosting and running the Trigger.dev platform locally
54 stars 17 forks source link

Magic Link not received. #5

Open shaaridev opened 1 month ago

shaaridev commented 1 month ago

Hi,

I followed the tutorial https://trigger.dev/docs/open-source-self-hosting to sel host trigger.dev.

But when I try to signup using npx trigger.dev@latest login -a http://localhost:3040/ I'm not getting the magic link in my email inbox ! I used a gmail email for testing.

Is there something wrong or missing in my .env that prevent me from getting the magic link by email ? Any help is highly appreciated.

These are values of my environment variables that related to resend.com and magic link in my .env file :

#WHITELISTED_EMAILS=  #commented not active

# Accounts with these emails will become admins when signing up and get access to the admin panel
ADMIN_EMAILS=  #commented not active

.....
## E-mail settings
FROM_EMAIL=email used to create for resend.com account
REPLY_TO_EMAIL=email used to create for resend.com account 
RESEND_API_KEY=API key from resend.com

MAGIC_LINK_SECRET=generated using echo MAGIC_LINK_SECRET=$(openssl rand -hex 16)
SESSION_SECRET=generated using echo SESSION_SECRET=$(openssl rand -hex 16)
ENCRYPTION_KEY=generated using echo ENCRYPTION_KEY=$(openssl rand -hex 16)
PROVIDER_SECRET=generated using echo PROVIDER_SECRET=$(openssl rand -hex 32)
COORDINATOR_SECRET=generated using  echo COORDINATOR_SECRET=$(openssl rand -hex 32)

The rest of the environment variables contain the default values from .env.example

Thank you

nicktrn commented 1 month ago

Hi @shaaridev, I've added a new auth section this morning which should clarify this: https://trigger.dev/docs/open-source-self-hosting#auth-options

If RESEND_API_KEY is not set, no emails can be sent and the magic links are instead logged by the webapp. You can access the logs by running this: docker logs -f trigger-webapp-1

shaaridev commented 1 month ago

@nicktrn Thank you the quick reply .

*1

When I use docker logs -f trigger-webapp-1 I'm getting the requestId and not magicLink Token

{"email":"myEmail@gmail.com","magicLinkVerify":false,"http":{"requestId":"qrv7PpqWSqKEV6RVnMxXP","path":"/login/magic?_data=routes%2Flogin.magic","host":"e1a2-197-26-240-179.ngrok-free.app"},"timestamp":"2024-09-25T12:01:53.804Z","name":"webapp","message":"Magic link user authenticated","level":"info"}
{"emailAddress":"myEmail@gmail.com","http":{"requestId":"qrv7PpqWSqKEV6RVnMxXP","path":"/login/magic?_data=routes%2Flogin.magic","host":"e1a2-197-26-240-179.ngrok-free.app"},"timestamp":"2024-09-25T12:01:53.825Z","name":"webapp","message":"Sending magic link email","level":"debug"}

*2

check my previous message I did setup RESEND_API_KEY with key I got from resend.com so it should work

nicktrn commented 1 month ago

Ah right, I didn't see that part. Nothing in the Resend dashboard? No errors logged by the webapp? I think there may be an additional step required on the Resend side by authenticating your FROM address.

shaaridev commented 1 month ago

@nicktrn

These are the steps I taken taken in Resend.com 1 create resend account using my email 2 then create and api key with these settings : full access and all domains 3- fill .env like this

## E-mail settings
FROM_EMAIL=email used to create for resend.com account
REPLY_TO_EMAIL=email used to create for resend.com account 
RESEND_API_KEY=API key from resend.com

I think the issue is that email domain has to be setup I checked resend logs :

{
    "name": "validation_error",
    "message": "The <mydomain>.com domain is not verified. Please, add and verify your domain on https://resend.com/domains",
    "statusCode": 403
}

I will contact the domain admin to add it and update this ticket after I test it.

I think it will nice to have the magic token in the outout of docker logs -f trigger-webapp-1 in case resend.com is not accessible .