Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cute-frogs-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/backend': minor
---

Optimzie satellite sync flow to reduce redirects.
9 changes: 8 additions & 1 deletion packages/backend/src/tokens/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,15 @@ export const authenticateRequest: AuthenticateRequest = (async (
}
}
}

// Only trigger satellite sync handshake if we don't have session cookies.
// If we have cookies, the client is already linked - fall through to normal
// verification flow which can leverage the refresh flow for expired tokens
// instead of requiring a full multi-domain handshake.
const isLinked = authenticateContext.clientUat && authenticateContext.sessionTokenInCookie;

const isRequestEligibleForMultiDomainSync =
authenticateContext.isSatellite && authenticateContext.secFetchDest === 'document';
authenticateContext.isSatellite && authenticateContext.secFetchDest === 'document' && !isLinked;

/**
* Begin multi-domain sync flows
Expand Down