Skip to content

Fix Safari 404 on donate button by using canonical URL#981

Merged
busbyk merged 3 commits intomainfrom
canonical-url-for-donate-button
Mar 9, 2026
Merged

Fix Safari 404 on donate button by using canonical URL#981
busbyk merged 3 commits intomainfrom
canonical-url-for-donate-button

Conversation

@busbyk
Copy link
Collaborator

@busbyk busbyk commented Mar 7, 2026

Description

Fixes a Safari-only bug where clicking the donate button results in a 404. The donate nav item was linking to /{slug} (e.g., /donate), relying on a server-side redirect() to the canonical nested URL (/support/donate). Safari mishandles this redirect — likely due to a duplicate Location header bug in Next.js (vercel/next.js#82117) — producing a mangled URL like /support/donate,%20/support/donate.

The fix resolves the canonical URL at nav-build time by looking up the donate page in the already-built navigation tree using findNavigationItemBySlug, avoiding the redirect entirely.

Related Issues

Fixes #746

Related upstream issues:

Key Changes

  • src/components/Header/utils.ts: After building the donate NavLink, if it's an internal page link, look up the page's slug in the already-built topLevelNavItems to get the canonical (navigation-nested) URL. This means the donate button links directly to e.g. /support/donate instead of /donate, bypassing the problematic redirect.

How to test

  1. On a tenant with a donate page nested under Support (e.g., SAC, Sierra), verify the donate button in the nav links to the canonical nested URL (e.g., /support/donate) rather than the bare slug (/donate)
  2. Test in Safari specifically — clicking the donate button should navigate correctly without a 404
  3. Verify other nav items still work correctly

Screenshots / Demo video

Demo: https://www.loom.com/share/3acc89bf68a9405480312972784bfe4d

Migration Explanation

No migration needed — this is a runtime behavior change only.

Future enhancements / Questions

The donate nav item was linking to /{slug} (e.g. /donate), relying on a
server-side redirect to the canonical nested URL (e.g. /support/donate).
Safari mishandles this redirect due to a duplicate Location header bug in
Next.js (vercel/next.js#82117), producing a mangled URL like
/support/donate,%20/support/donate.

Resolve the canonical URL at nav-build time by looking up the page in the
already-built navigation tree, avoiding the redirect entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@busbyk busbyk self-assigned this Mar 7, 2026
@busbyk busbyk requested a review from rchlfryn March 7, 2026 19:01
@github-actions
Copy link
Contributor

github-actions bot commented Mar 7, 2026

@busbyk
Copy link
Collaborator Author

busbyk commented Mar 7, 2026

We may also want to set this in our next config: vercel/next.js#82117 (comment)

Copy link
Collaborator

@rchlfryn rchlfryn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG - did you test the preview link on Safari?

Also I don't see why we wouldn't include the workaround in our next config.

@busbyk
Copy link
Collaborator Author

busbyk commented Mar 8, 2026

LG - did you test the preview link on Safari?

I added the redirect logic (which was definitely still necessary! I had just been focused on making sure we were using the navigation-nested (canonical) url for internal links for the donate button) and recorded a demo (see the PR description).

Ready for re-review.

@busbyk busbyk requested a review from rchlfryn March 8, 2026 17:27
@busbyk busbyk added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit 9259ae8 Mar 9, 2026
9 checks passed
@busbyk busbyk deleted the canonical-url-for-donate-button branch March 9, 2026 20:42
@github-actions
Copy link
Contributor

🚀 This is included in version v1.11.0

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.

404 on SAC Donate page in Safari

2 participants