fix(web): joinByCode normalizes explicit home origin to local

When a caller passes the user's own instance origin (e.g. from an invite
snapshot's spaceInstanceOrigin), strip it to undefined before the remote
branch so the local api path is taken instead of erroneously failing with
NotConnectedError. Mirrors inviteParser's identical normalization.
This commit is contained in:
Jannis Braun
2026-04-29 22:52:47 +02:00
parent 85987a891c
commit 9aa97f4552
2 changed files with 97 additions and 0 deletions
+5
View File
@@ -347,6 +347,11 @@ export const useSpaceStore = create<SpaceState>((set, get) => ({
},
joinByCode: async (inviteCode: string, origin?: string) => {
// Normalize: an explicit home origin is equivalent to undefined (local).
// Mirrors inviteParser's same normalization at the URL boundary.
if (origin && typeof window !== 'undefined' && origin === window.location.origin) {
origin = undefined;
}
if (origin) {
// Remote instance — verify connectivity via dynamic import (avoids circular dep)
const { useInstanceStore } = await import('./instanceStore');