Skip to content

Commit 2b8596d

Browse files
committed
Fix custom domain session discovery
1 parent 3f81d8a commit 2b8596d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/appwrite-utils-helpers/src/config/services/SessionAuthService.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,24 @@ export class SessionAuthService {
595595
return null;
596596
}
597597

598-
const candidates = this.getSessionsForEndpoint(prefs, endpoint);
598+
let candidates = this.getSessionsForEndpoint(prefs, endpoint);
599599
if (candidates.length === 0) {
600-
logger.debug("No candidate sessions found for endpoint", {
600+
logger.debug("No endpoint-matched sessions, trying all sessions as cross-endpoint fallback", {
601601
prefix: "Session",
602602
endpoint,
603603
normalizedEndpoint: this.normalizeEndpoint(endpoint)
604604
});
605+
// Fallback: try ALL sessions regardless of endpoint (handles custom domains like
606+
// appwrite.socialaize.com pointing to cloud.appwrite.io)
607+
candidates = Object.entries(prefs)
608+
.filter(([key, data]) =>
609+
key !== 'current' &&
610+
typeof data === 'object' &&
611+
data?.endpoint &&
612+
data?.cookie
613+
) as typeof candidates;
614+
}
615+
if (candidates.length === 0) {
605616
return null;
606617
}
607618

0 commit comments

Comments
 (0)