Skip to content

fix: proxy API via Pages Function to fix iOS Safari guest sessions#22

Merged
pkmaster21 merged 2 commits intomainfrom
fix/ios-safari-guest-session-cookie
Apr 16, 2026
Merged

fix: proxy API via Pages Function to fix iOS Safari guest sessions#22
pkmaster21 merged 2 commits intomainfrom
fix/ios-safari-guest-session-cookie

Conversation

@pkmaster21
Copy link
Copy Markdown
Owner

Problem

Guest sign-in was broken on mobile. After joining a group, navigating to the dashboard immediately showed "Session expired. Open the group link again to rejoin."

The root cause is iOS Safari's Intelligent Tracking Prevention (ITP). When the frontend (tabby.pages.dev) makes a cross-origin fetch() to the API with credentials: 'include', Safari blocks the Set-Cookie response header — even with SameSite=None; Secure set correctly. The guest session token is never stored, so every subsequent API call returns a 401.

Solution

Added a Cloudflare Pages Function (functions/api/[[path]].ts) that proxies all /api/* requests to the backend at the edge. With the proxy in place, the frontend makes same-origin requests to tabby.pages.dev/api/..., so cookies are first-party and Safari stores them normally.

To complete the fix, update the Cloudflare Pages dashboard:

  • Add env var API_URL = the current value of VITE_API_URL (the backend URL)
  • Set VITE_API_URL to an empty string (or remove it)

…est sessions

iOS Safari's ITP blocks Set-Cookie headers from cross-origin fetch() requests,
even with SameSite=None; Secure, causing guest session tokens to never be stored.
Adds a catch-all Pages Function that proxies /api/* to the backend API_URL so all
requests are same-origin and cookies are treated as first-party.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 16, 2026

Deploying tabby with  Cloudflare Pages  Cloudflare Pages

Latest commit: 16c06fa
Status: ✅  Deploy successful!
Preview URL: https://38a79cf0.tabby.pages.dev
Branch Preview URL: https://fix-ios-safari-guest-session.tabby.pages.dev

View logs

@pkmaster21 pkmaster21 merged commit 27e87b8 into main Apr 16, 2026
7 checks passed
@pkmaster21 pkmaster21 deleted the fix/ios-safari-guest-session-cookie branch April 16, 2026 05:47
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