Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localhost magic link redirect on Safari (MacOS) #1384

Open
shaaridev opened this issue Oct 5, 2024 · 9 comments
Open

Localhost magic link redirect on Safari (MacOS) #1384

shaaridev opened this issue Oct 5, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@shaaridev
Copy link

Provide environment information

System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M2
Memory: 77.13 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.2.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.7.0 - /opt/homebrew/bin/npm

Describe the bug

In safari Browser on mac after you click on the magic link from the email the browser redirect you to the login page ]
http://localhost:3040/login?redirectTo=%2F which show you the login page again.
This works without issues in chrome. I get redirected to http://localhost:3040/confirm-basic-details

Reproduction repo

https://github.com/triggerdotdev/docker

To reproduce

git clone https://github.com/triggerdotdev/docker
cd docker
cp .env.example .env
follow the self hosting tutorial in the doc to set .env
..
./start.sh
go to http://localhost:3040/ in Safari (MacOs)
create account and check your email.
click on the magic link

Additional information

No response

@matt-aitken matt-aitken changed the title bug: Magic Link redirect on Safari (MacOs) Localhost magic Link redirect on Safari (MacOS) Oct 6, 2024
@matt-aitken matt-aitken added the bug Something isn't working label Oct 6, 2024
@matt-aitken matt-aitken changed the title Localhost magic Link redirect on Safari (MacOS) Localhost magic link redirect on Safari (MacOS) Oct 6, 2024
@smoothdvd
Copy link

same here, Safari 18.1 (20619.2.8.11.10) / macOS 15.1 / trigger.dev docker 3.1.1

@nicktrn
Copy link
Collaborator

nicktrn commented Nov 3, 2024

Are you both testing this on localhost? Webapp and worker on the same machine or split setup? Likely an env var issue as it worked fine when I just tried it with:

git clone https://github.com/triggerdotdev/docker trigger-docker
cd trigger-docker
./start.sh
# then login at http://localhost:3040/

I'd start fresh an see after which step it fails, my guess is it's one of these env vars:

# Only uncomment these once you've set up a domain and are trying to access the webapp through it
# On localhost, these should be commented out as below
# TRIGGER_PROTOCOL=https
# TRIGGER_DOMAIN=<your_subdomain>.ngrok-free.app

For a completely fresh start, you can nuke your DB, reset your .env and pull in any changes like so:

./stop.sh -v
rm .env
git pull
./start.sh

@smoothdvd
Copy link

This doesn’t explain why it works on Chrome but not on Safari.

@nicktrn
Copy link
Collaborator

nicktrn commented Nov 5, 2024

Ah right, I didn't see that part! This sounds familiar - I think we had an issue with magic links on Safari before. #186

@smoothdvd
Copy link

I found TRIGGER_PROTOCOL env not working when I set WEBAPP_PUBLISH_IP=192.168.1.x. It still runs on local , but magic link always generate https link even set TRIGGER_PROTOCOL=http.

@nicktrn
Copy link
Collaborator

nicktrn commented Nov 5, 2024

I don't think that WEBAPP_PUBLISH_IP should change anything, but it's possible that TRIGGER_PROTOCOL is being ignored. Is this the full or split setup? Also, when changing any env vars, make sure to restart all services. ./stop.sh && ./start.sh should do it.

@smoothdvd
Copy link

@nicktrn I use the full setup to self-host Trigger.dev on a home server. I set WEBAPP_PUBLISH_IP=192.168.1.x to allow another client PC to access it via http://192.168.1.x:3040.

@nicktrn
Copy link
Collaborator

nicktrn commented Nov 7, 2024

I found TRIGGER_PROTOCOL env not working when I set WEBAPP_PUBLISH_IP=192.168.1.x. It still runs on local , but magic link always generate https link even set TRIGGER_PROTOCOL=http.

Okay, I tracked this down to the external package we're using for magic link auth. It sets the protocol to "https" unless you're accessing the webapp via "localhost" or "127.0.0.1".

image

I don't see us changing this because it's very niche.

You could solve both problems quite easily if you're only accessing the webapp locally and have no need to secure logins. Setting
NODE_ENV=development in your .env will disable magic link auth and log you in automatically.

An alternative would be to access the webapp only via the external domain, even when accessing on your local network.

@smoothdvd
Copy link

@nicktrn Thank you for help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants