Skip to content

fix: use SameSite=Lax for session cookies to fix iOS Chrome sessions#24

Merged
pkmaster21 merged 1 commit intomainfrom
fix/ios-samesite-cookie
Apr 16, 2026
Merged

fix: use SameSite=Lax for session cookies to fix iOS Chrome sessions#24
pkmaster21 merged 1 commit intomainfrom
fix/ios-samesite-cookie

Conversation

@pkmaster21
Copy link
Copy Markdown
Owner

Problem

Users creating or joining groups on Chrome (or any browser) on iPhone were immediately seeing "Session expired. Open the group link again to rejoin." The previous fix — proxying API calls through a Cloudflare Pages Function so cookies would be same-origin — was deployed but didn't fully solve the issue.

The remaining problem was the SameSite=None cookie attribute. iOS WebKit (the rendering engine used by every browser on iPhone, including Chrome) applies ITP (Intelligent Tracking Prevention) restrictions to SameSite=None cookies, including first-party cookies set via fetch() responses. The browser would not store the cookie, so the very next API request after group creation came back 401.

Changes

Cookie SameSite attribute (auth.ts, groups.ts, members.ts): Changed all session cookie sameSite from process.env['NODE_ENV'] === 'prod' ? 'none' : 'lax' to a constant 'lax'. Since all API requests now go through the same-origin Pages Function proxy, SameSite=Lax is correct and sufficient — same-site requests include the cookie regardless of SameSite value.

Pages Function proxy (functions/api/[[path]].ts): Fixed Set-Cookie forwarding to skip set-cookie in the forEach loop and instead use Cloudflare's headers.getAll('set-cookie') extension. The Cloudflare Workers Headers.forEach() implementation collapses multiple Set-Cookie entries into a single comma-joined string, which breaks cookie parsing. getAll() preserves them as individual entries.

…sions

SameSite=None was causing iOS WebKit (used by all browsers on iPhone,
including Chrome) to drop session cookies due to ITP restrictions, even
for first-party cookies set via fetch() responses. Since all API calls
now go through the same-origin Cloudflare Pages Function proxy, there
is no need for SameSite=None — SameSite=Lax works correctly for
same-site requests and is fully trusted by iOS WebKit.

Also fixes the Pages Function proxy to use getAll('set-cookie') instead
of forEach() when forwarding Set-Cookie headers, preventing the
Cloudflare Workers runtime from collapsing multiple cookies into a
single comma-joined string.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying tabby with  Cloudflare Pages  Cloudflare Pages

Latest commit: de71bbe
Status: ✅  Deploy successful!
Preview URL: https://ae83300a.tabby.pages.dev
Branch Preview URL: https://fix-ios-samesite-cookie.tabby.pages.dev

View logs

@pkmaster21 pkmaster21 merged commit c166847 into main Apr 16, 2026
7 checks passed
@pkmaster21 pkmaster21 deleted the fix/ios-samesite-cookie branch April 16, 2026 17:13
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.

1 participant