Skip to content

fix: Safari magic link redirect on MacOS - #4464

Closed
deepshekhardas wants to merge 1 commit into
triggerdotdev:mainfrom
deepshekhardas:fix/1384-safari-magic-link-redirect
Closed

fix: Safari magic link redirect on MacOS#4464
deepshekhardas wants to merge 1 commit into
triggerdotdev:mainfrom
deepshekhardas:fix/1384-safari-magic-link-redirect

Conversation

@deepshekhardas

Copy link
Copy Markdown

Fixes #1384 - Safari magic link redirect on MacOS.

@changeset-bot

changeset-bot Bot commented Aug 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 96e5ff0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Hi @deepshekhardas, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions Bot closed this Aug 2, 2026
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 11fdc6d2-e06f-4076-9563-374c83ffebfa

📥 Commits

Reviewing files that changed from the base of the PR and between 14824b0 and 96e5ff0.

📒 Files selected for processing (1)
  • apps/webapp/app/services/sessionStorage.server.ts

Walkthrough

The session cookie sameSite policy now uses "none" in production and "lax" in non-production environments.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

View 1 additional finding in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Server-change note appears to be missing for this webapp-only change

CONTRIBUTING.md requires a .server-changes/ markdown file when a PR only touches server components under apps/webapp/. This PR only modifies apps/webapp/app/services/sessionStorage.server.ts and does not appear to add one, so the fix would not show up in release notes.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

cookie: {
name: "__session",
sameSite: "lax",
sameSite: env.NODE_ENV === "production" ? "none" : "lax",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Login sessions become unreliable on older Safari and lose cross-site protection

The login cookie is now sent on every cross-site request in production (sameSite: "none" at apps/webapp/app/services/sessionStorage.server.ts:14) instead of only same-site navigations, so users on older Safari versions can be silently signed out and every logged-in user's browser will attach their session to requests started by other websites.
Impact: Some users cannot stay logged in, and all users' dashboard actions can be triggered from other sites while they are signed in.

Why SameSite=None does not fix the magic-link case but does break other behaviour

A magic-link click is a top-level GET navigation, which is already allowed by SameSite=Lax; therefore None is not required for that flow. Meanwhile:

  • Safari 12 (macOS 10.14) / iOS 12 implement the older spec and treat the literal value None as Strict, so the __session cookie stops being sent on cross-site navigations at all — the exact browser family the PR aims to fix.
  • The webapp has no CSRF token layer (only sameSite: "lax" comments in apps/webapp/app/services/onboardingSession.server.ts:7 and apps/webapp/app/services/impersonation.server.ts:12), so Lax on __session is the sole protection for all Remix form actions. Setting None removes it.
  • The change is also inconsistent with every other cookie in the app (redirectTo, impersonation, lastAuthMethod, uiPreferences, github/google auth state), which all remain lax; if a cross-site cookie really were needed for the login flow, redirectTo would still fail.
Prompt for agents
The PR changes the main __session cookie to SameSite=None in production to work around a Safari magic-link redirect issue (#1384). This is unlikely to be the correct root-cause fix: magic-link clicks are top-level GET navigations, which SameSite=Lax already permits. Meanwhile SameSite=None (a) is interpreted as Strict by Safari 12/iOS 12, potentially worsening the exact scenario being fixed, and (b) removes the only CSRF mitigation the webapp has, since there is no CSRF token middleware and all other cookies in apps/webapp/app/services/*.server.ts stay on lax. Investigate the actual Safari failure: check whether the magic-link handler performs a cross-origin redirect (LOGIN_ORIGIN vs APP_ORIGIN in app/env.server.ts) that causes the Set-Cookie to be dropped, or whether Safari's link prefetch/preview consumes the one-time magic link before the user clicks. Prefer keeping sameSite lax and fixing the redirect/origin handling, or, if a cross-site cookie is genuinely required, apply it consistently to redirectTo and add CSRF token verification.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

cookie: {
name: "__session",
sameSite: "lax",
sameSite: env.NODE_ENV === "production" ? "none" : "lax",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Self-hosted HTTP deployments and SameSite=None

SameSite=None cookies are rejected outright by modern browsers unless they also carry Secure. Here secure is env.NODE_ENV === "production" (apps/webapp/app/services/sessionStorage.server.ts:18), so the two flags stay in sync today. However, self-hosters who terminate TLS incorrectly or run the container over plain HTTP with NODE_ENV=production would now have the login cookie silently discarded rather than merely being insecure — worth confirming against the self-hosting docs before merging.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Localhost magic link redirect on Safari (MacOS)

1 participant