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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user