Skip to content

fix(relay,desktop): surface CORS rejections and split invite mint/copy errors (#3636) - #4278

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/3636-cors-invite-diagnostics
Open

fix(relay,desktop): surface CORS rejections and split invite mint/copy errors (#3636)#4278
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/3636-cors-invite-diagnostics

Conversation

@iroiro147

Copy link
Copy Markdown

Two independent fixes for the same failure class reported in #3636: a misconfigured BUZZ_CORS_ORIGINS produces invisible failures that cost self-hosters hours.

Fix 1: warn-log rejected CORS origins (relay)

crates/buzz-relay/src/router.rs

Before, a non-allowlisted origin was silently refused by the outermost CORS layer and never reached the inner trace layer — no log line at any RUST_LOG level. Now every rejected origin is logged at warn! with the received origin value.

Fix 2: split invite mint/copy error paths (desktop)

desktop/src/features/community-members/ui/InviteLinkSection.tsx

Before, the combined try around mintInvite + writeTextToClipboard collapsed any mintInvite failure (CORS, NIP-98 401/403, timeout, 5xx) into the misleading toast "Couldn't copy the invite link" — sending users to clipboard permissions instead of the actual network error. Mint failures now surface the underlying error.message from invitePost; clipboard failures keep a distinct message, which matters because the minted invite (stored only as token_hash in relay_invites) is unrecoverable after a failed clipboard write.

Fixes #3636.

…y errors (block#3636)

Two independent fixes for the same class: a misconfigured BUZZ_CORS_ORIGINS produces invisible failures costing self-hosters hours.

Relay (router.rs):
- Add warn! for every rejected CORS origin inside the existing AllowOrigin predicate. Before, a non-allowlisted origin was silently refused by the outer CORS layer and never reached the inner trace layer, so no log at any RUST_LOG level.

Desktop (InviteLinkSection.tsx):
- Split combined try around mintInvite + writeTextToClipboard into two error paths. Before, any mintInvite failure (CORS, NIP-98, 403, timeout, 5xx) surfaced as "Couldn't copy the invite link" — sending users to clipboard permissions instead of the real error. Mint failures now surface error.message; clipboard failures keep the old wording, distinguishing from mint failures since the minted invite (stored only as token_hash in relay_invites) is unrecoverable after a clipboard failure.

Verified:
- cargo check -p buzz-relay --lib clean
- cargo clippy -p buzz-relay --lib zero warnings
- cargo test -p buzz-relay --lib handlers::side_effects 5/5
- npx tsc --noEmit clean
- Desktop webview tests: 3906/3906 pass

Signed-off-by: Sarthak Singh <sarthak.singh@juspay.in>
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.

A rejected CORS preflight is invisible on both sides: no relay log at any level, and the desktop reports it as a clipboard failure

1 participant