mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem
Studio switched project URLs to the custom domain when the Cloudflare
hostname reported `active`, which already happens at
`4_origin_setup_completed`. At that point the platform services don't
accept requests on the custom domain yet. So URLs Studio handed out,
such as the Storage explorer's **Get URL** links, failed until
activation finished.
## Solution
`useProjectApiUrl` now uses the custom domain only when the
custom-hostname status is `5_services_reconfigured`. Before that it
returns the project's own host. Every Studio surface that builds project
URLs reads this hook, so Storage **Get URL**, the Connect sheet, API
settings, and Edge Functions all follow the same rule.
## How to verify
1. Open a project with the custom domain add-on whose domain is in
`4_origin_setup_completed` (verified, not yet activated). In Storage,
click **Get URL** on a file. The copied URL uses the project's
`supabase.co` host.
2. On a project whose custom domain is in `5_services_reconfigured`
(activated), **Get URL** copies a URL on the custom domain.
3. On a project with no custom domain, **Get URL** copies a URL on the
project's `supabase.co` host, as before.
4. `pnpm exec vitest run
data/config/project-endpoint-query.platform.test.tsx` from `apps/studio`
passes. The status-4 case fails without this change.
## Checks
From `apps/studio`: `tsc --noEmit` (passed); `eslint` and the type-aware
`eslint.type-checks.config.cjs` on the changed files (passed); `vitest
run` on the new test plus `ProjectConnectionPopover.platform.test.tsx`
and `TerminalInstructions.platform.test.tsx` (passed). `oxfmt --check`
on the changed files (passed). Checked the status values against
`packages/api-types` (`/v1/projects/{ref}/custom-hostname`) and against
`CustomDomainConfig.tsx`, which treats status 4 as "ready to activate".
## Checklist
- [x] I have read the [Contributing
Guidelines](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] I have added tests where applicable
- [ ] I have checked that the change works in the preview deployment
## Feedback for Tedd
To ask Tedd for a change to this PR, reply in Tedd's session on
[FE-5306](https://linear.app/supabase/issue/FE-5306/studio-uses-custom-domain-before-domain-is-fully-activated).
Tedd doesn't read comments on this PR.
---------
Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>