Files
supabase/apps/studio/compat
Alaister YoungandAlaister Young 167c633ed0 fix(studio): treat same-origin URLs outside basePath as external in TanStack (#52441)
In the TanStack build, links from the dashboard to other pages on the
same origin (e.g. `https://supabase.com/docs/...` from `/dashboard`)
were treated as internal routes and got the basepath prepended, landing
on `/dashboard/docs/...`. Next only treats an absolute URL as local when
it's same-origin **and** under the basePath, so this matches that
behavior.

**Changed:**
- `splitInternalUrl` leaves absolute same-origin URLs outside
`NEXT_PUBLIC_BASE_PATH` untouched, so the `next/link` shim renders a
plain anchor. Relative paths are always internal, and nothing changes
when no basePath is set
- The `next/router` shim's `push`/`replace` now do a document navigation
for absolute external targets. Previously TanStack resolved an absolute
`to` as a relative path segment, so `router.push` to any external URL
(cross-origin too) stayed inside the app
- `prefetch` skips external targets

**Added:**
- Unit tests for `splitInternalUrl`, plus shim tests rendering the real
Link/router under a `/dashboard` basepath

## To test

- Only reproducible where docs and the dashboard share an origin (i.e.
prod `supabase.com/dashboard`). On previews, confirm nothing regressed:
- New project → pick a paid compute size on a Pro org → submit → in
"Confirm compute costs", the "Compute Costs" link opens the compute docs
in a new tab
- Click a few other docs links (e.g. in project settings) – they open
the docs, not a dashboard 404
- Normal in-app navigation (sidebar, table editor links) still navigates
client-side without full reloads

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
2026-10-28 19:23:11 +08:00
..