Skip to content

feat: Redirect to canonical node/publisher IDs when URL contains legacy IDs#253

Closed
Copilot wants to merge 1 commit into
sno-node-302from
copilot/sub-pr-237
Closed

feat: Redirect to canonical node/publisher IDs when URL contains legacy IDs#253
Copilot wants to merge 1 commit into
sno-node-302from
copilot/sub-pr-237

Conversation

Copilot AI commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

When the backend returns a node.id or node.publisher.id that differs from the URL params, the page previously rendered with stale IDs. This adds client-side redirect logic to canonicalize URLs for both /nodes/[nodeId] and /publishers/[publisherId]/nodes/[nodeId] routes.

Changes

  • isNodeIdMismatched / isPublisherIdMismatched flags — computed outside effects, gated on router.isReady and !!node?.id to prevent premature or undefined-producing redirects
  • Two useEffect-based redirects replacing inline redirect + return null — avoids SSR issues
  • Conflict prevention — publisherId effect early-returns when isNodeIdMismatched is true; only one router.replace fires per render cycle
  • Canonical node.id in publisher redirect — uses node.id (not URL nodeId) so a combined publisher+node ID mismatch resolves in one hop
  • Spinner during redirectisRedirecting merged into shouldShowLoading prevents stale IDs from being visible or interactable before navigation completes
const isNodeIdMismatched = router.isReady && !!node?.id && !!nodeId && node.id !== nodeId;
const isPublisherIdMismatched =
  router.isReady && !!node?.id && !!_publisherId && !!publisherId && !!nodeId && publisherId !== _publisherId;

// publisherId effect yields to nodeId effect — no competing router.replace
useEffect(() => {
  if (!isPublisherIdMismatched || isNodeIdMismatched) return;
  router.replace(`/publishers/${publisherId}/nodes/${node!.id}`);
}, [router, node, isPublisherIdMismatched, isNodeIdMismatched, publisherId]);

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@vercel

vercel Bot commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
registry-web Ready Ready Preview, Comment Mar 8, 2026 11:27am

Request Review

Copilot AI changed the title [WIP] Add redirect logic for mismatched node IDs in API response feat: Redirect to canonical node/publisher IDs when URL contains legacy IDs Mar 8, 2026
@snomiao snomiao closed this Mar 23, 2026
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.

2 participants