The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: update custom domain docs (#19865)
Stojan Dimitrovski42ca8be75b17
diff --git a/apps/docs/pages/guides/platform/custom-domains.mdx b/apps/docs/pages/guides/platform/custom-domains.mdxindex b7ce3eff52b..a0a251d89da 100644--- a/apps/docs/pages/guides/platform/custom-domains.mdx+++ b/apps/docs/pages/guides/platform/custom-domains.mdx@@ -3,11 +3,11 @@ import Layout from '~/layouts/DefaultGuideLayout'export const meta = {id: 'custom-domains',title: 'Custom Domains',- description: 'Configuring a Custom Domain for your Supabase project.',+ description: 'Use a custom domain instead of the default Supabase domain for your project.',video: 'https://www.youtube.com/v/6rcGnW_Mh-0',}-Custom domains allow you to present a branded experience to your users. Custom domains are available as a [add-on for projects on a paid plan](https://supabase.com/dashboard/project/_/settings/addons?panel=customDomain). Setting up a custom domain requires [Owner or Admin permissions](/docs/guides/platform/access-control#manage-team-members) for the project. Currently, you must use a subdomain (e.g., `api.example.com`, rather than `example.com`) for the purposes of this guide.+Custom domains allow you to present a branded experience to your users. These are available as an [add-on for projects on a paid plan](/dashboard/project/_/settings/addons?panel=customDomain).<div className="video-container"><iframe@@ -18,139 +18,213 @@ Custom domains allow you to present a branded experience to your users. Custom d></iframe></div>-## Configure a custom domain using the Supabase dashboard+There are two types of domains supported by Supabase:++1. Custom domains, where you use a domain such as `api.example.com` instead of the project's default domain.+2. Vanity subdomains (experimental), where you can set up a different subdomain on `supabase.co` for your project.++You can choose either a custom domain or vanity subdomain for each project.++## Custom domains++Custom domains change the way your project's URLs appear to your users. This is useful when:++- You are using [OAuth (Social Login)](/docs/guides/auth/social-login) with Supabase Auth and the project's URL is shown on the OAuth consent screen.+- You are creating APIs for third-party systems, for example, implementing webhooks or external API calls to your project via [Edge Functions](/docs/guides/functions).+- You are storing URLs in a database or encoding them in QR codes.++Custom domains help you keep your APIs portable for the long term. By using a custom domain you can migrate from one Supabase project to another, or make it easier to version APIs in the future.++### Configure a custom domain using the Supabase dashboardFollow the **Custom Domains** steps in the [General Settings](https://supabase.com/dashboard/project/_/settings/general) page in the Dashboard to set up a custom domain for your project.-## Configure a custom domain using the Supabase CLI+### Configure a custom domain using the Supabase CLI-This example assumes your Supabase project is `foobarbaz` with a corresponding API URL `foobarbaz.supabase.co` and configures a custom domain at `api.example.com`.+This example assumes your Supabase project is `abcdefghijklmnopqrst` with a corresponding API URL `abcdefghijklmnopqrst.supabase.co` and configures a custom domain at `api.example.com`.To get started:-1. [Install](/docs/guides/resources/supabase-cli) the Supabase CLI 1.11.3+.-1. [Log in](/docs/guides/resources/supabase-getting-started/local-development#log-in-to-the-supabase-cli) to your Supabase account using the CLI.+1. [Install](/docs/guides/resources/supabase-cli) the latest version of the Supabase CLI.+2. [Log in](/docs/guides/resources/supabase-getting-started/local-development#log-in-to-the-supabase-cli) to your Supabase account using the CLI.+3. Ensure you have [Owner or Admin permissions](/docs/guides/platform/access-control#manage-team-members) for the project.+4. Get a custom domain from a DNS provider. Currently, only subdomains are supported.+ - Use `api.example.com` instead of `example.com`.++### Add a CNAME record-### Configure a CNAME+You need to add a CNAME record to your domain's DNS settings to ensure your custom domain points to the Supabase project.-Set up a CNAME record for `api.example.com`, resolving to `foobarbaz.supabase.co.`, with as low a TTL as possible.+If your project's default domain is `abcdefghijklmnopqrst.supabase.co` you should:-### Configure TXT verification+- Create a CNAME record for `api.example.com` that resolves to `abcdefghijklmnopqrst.supabase.co.`.+- Use a low TTL value to quickly propagate changes in case you make a mistake.-Use the `create` subcommand of the CLI to notify Supabase of your domain and retrieve TXT verification records:+### Verify ownership of the domain++Register your domain with Supabase to prove that you own it. You need to download two TXT records and add them to your DNS settings.++In the CLI, run [`domains create`](/docs/reference/cli/supabase-domains-create) to register the domain and Supabase and get your verification records:```bash-supabase domains create --project-ref foobarbaz --custom-hostname api.example.com --experimental+supabase domains create --project-ref abcdefghijklmnopqrst --custom-hostname api.example.com```-The output of the `create` command includes two TXT records[^1] you will need to set up, in order to verify your control over the domain in question,-and for us to issue SSL certificates for it. For example:+Two TXT records are returned. For example:-```bash+```text[...]Required outstanding validation records:_cf-custom-hostname.api.example.com TXT -> 46BBC14D-D50A-409C-8DB5-F862CF5BA660api.example.com TXT -> ca3-F1HvR9i938OgVwpCFwi1jTsbhe1hvT0Ic3efPY3Q```-[^1] One of the records requires you to _replace_ the CNAME record set up in [the first step](#configure-a-cname) with a TXT record. You'll be able to restore it back to the CNAME after the verification process has been completed.+Add the records to your domains' DNS settings. Make sure to trim surrounding whitespace. Use a low TTL value so you can quickly change the records if you make a mistake.### Verify your domain-Set up both records as instructed, and then use the `reverify` command for the Supabase Platform to verify the records:+Make sure you've configured all required DNS settings:++- CNAME for your custom domain pointing to the Supabase project domain.+- TXT record for `_cf-custom-hostname.<domain>`.+- TXT record for `<domain>`.++Use the [`domains reverify`](/docs/reference/cli/supabase-domains-reverify) command to begin the verification process of your domain. You may need to run this command a few times because DNS records take a while to propagate.```bash-supabase domains reverify --project-ref foobarbaz --experimental+supabase domains reverify --project-ref abcdefghijklmnopqrst```-You might need to wait a few minutes before your updated DNS records are propagated, especially if the older records were using a high TTL.+In the background, Supabase will check your DNS records and use [Let's Encrypt](https://letsencrypt.org) to issue a SSL certificate for your domain. This process can take up to 30 minutes.-### Activate your domain+### Prepare to activate your domain-The final activation step reconfigures your project to start serving traffic on your custom domain (`api.example.com`).-The auth service, in particular, will no longer work with the original URL (`foobarbaz.supabase.co`).-As such, it is recommended that you schedule a downtime window of 20-30 minutes, depending on the complexity of your project, to update all the services that need to know about your custom domain:+Before you activate your domain, prepare your applications and integrations for the domain change:-- Any client code (e.g., frontends, mobile apps). You can initialize a new Supabase client with your custom domain, `api.example.com`. For example:+- The project's Supabase domain remains active.+ - You do not need to change the Supabase URL in your applications immediately.+ - You can use it interchangeably with the custom domain.+- Supabase Auth will use the custom domain immediately once activated.+ - OAuth flows will advertize the custom domain as a callback URL.+ - SAML will use the custom domain instead. This means that the `EntityID` of your project has changed, and this may cause SAML with existing identity providers to stop working.- ```js- import { createClient } from '@supabase/supabase-js'+To prevent issues for your users, follow these steps:- // Use a custom domain as the supabase URL- const supabase = createClient('https://api.example.com', 'public-anon-key')- ```+1. For each of your Supabase OAuth providers:+ - In the provider's developer console (not in the Supabase dashboard), find the OAuth application and add the custom domain Supabase Auth callback URL **in addition to the Supabase project URL.** Example:+ - `https://abcdefghijklmnopqrst.supabase.co/auth/v1/callback` **and**+ - `https://api.example.com/auth/v1/callback`+ - [Sign in with Twitter](/docs/guides/auth/social-login/auth-twitter) uses cookies bound to the project's domain. Make sure your frontend code uses the custom domain instead of the default project's domain.+2. For each of your SAML identity providers:+ - Contact your provider and ask them to update the metadata for the SAML application. They should use `https://api.example.com/auth/v1/...` instead of `https://abcdefghijklmnopqrst.supabase.co/auth/v1/callback`.+ - Once these changes are made, SAML Single Sign-On will likely stop working until the domain is activated. Plan for this ahead of time.-- Any OAuth providers (e.g., google, github)+### Activate your domain-Additionally, update the DNS configuration for `api.example.com` to once more use a CNAME record that resolves to `foobarbaz.supabase.co`.-Finally, you can use the `activate` subcommand to reconfigure your project:+Once you've done the necessary preparations to activate the new domain for your project, you can activate it using the [`domains activate`](/docs/reference/cli/supabase-domains-activate) CLI command.```bash-supabase domains activate --project-ref foobarbaz --experimental+supabase domains activate --project-ref abcdefghijklmnopqrst```-## Remove a custom domain+When this step completes, Supabase will serve the requests from your new domain. The Supabase project domain **continues to work** and serve requests so you do not need to rush to change client code URLs.-If you have a custom domain (`api.example.com`) set up for your Supabase project (ref `foobarbaz`, with assigned endpoints at `foobarbaz.supabase.co`), and would like to go back to using the Supabase-provisioned endpoints (`foobarbaz.supabase.co`), you can use the `delete` subcommand:+If you wish to use the new domain in client code, change the URL used in your Supabase client libraries:-```bash-supabase domains delete --project-ref foobarbaz --experimental+```js+import { createClient } from '@supabase/supabase-js'++// Use a custom domain as the supabase URL+const supabase = createClient('https://api.example.com', 'public-anon-key')```-As with the final activation stage of the process for setting up a custom domain, you'll need to update any references in your client code and OAuth providers from the custom domain to the Supabase-provisioned endpoints.+### Remove a custom domain++Removing a custom domain may cause some issues when using Supabase Auth with OAuth or SAML. You may have to reverse the changes made in the _[Prepare to activate your domain](#prepare-to-activate-your-domain)_ step above.++To remove an activated custom domain you can use the [`domains delete`](/docs/reference/cli/supabase-domains-delete) CLI command.++```bash+supabase domains delete --project-ref abcdefghijklmnopqrst+```## Vanity subdomains-Vanity Subdomains allow you to present a basic branded experience, compared to custom domains. They allow you to host your services at a custom subdomain on Supabase (e.g., `my-example-brand.supabase.co`) instead of the default, randomly-assigned `foobarbaz.supabase.co`.+Vanity subdomains allow you to present a basic branded experience, compared to custom domains. They allow you to host your services at a custom subdomain on Supabase (e.g., `my-example-brand.supabase.co`) instead of the default, randomly assigned `abcdefghijklmnopqrst.supabase.co`.To get started:-1. [Install](/docs/guides/resources/supabase-cli) the Supabase CLI 1.22.0+.+1. [Install](/docs/guides/resources/supabase-cli) the latest version of the Supabase CLI.1. [Log in](/docs/guides/resources/supabase-getting-started/local-development#log-in-to-the-supabase-cli) to your Supabase account using the CLI.1. Ensure that you have [Owner or Admin permissions](/docs/guides/platform/access-control#manage-team-members) for the project you'd like to set up a vanity subdomain for.1. Ensure that your organization is on a paid plan (Pro/Team/Enterprise plan) in the [Billing page of the Dashboard](https://supabase.com/dashboard/org/_/billing).-## Configure a vanity subdomain+### Configure a vanity subdomain-This example assumes your Supabase project is `foobarbaz` with a corresponding API URL `foobarbaz.supabase.co` and configures a vanity subdomain at `my-example-brand.supabase.co`.+You can configure vanity subdomains via the CLI only.++Let's assume your Supabase project's domain is `abcdefghijklmnopqrst.supabase.co` and you wish to configure a vanity subdomain at `my-example-brand.supabase.co`.### Check subdomain availability-Use the `check-availability` subcommand of the CLI to check if your desired subdomain is available for use:+Use the [`vanity-subdomains check-availability`](/docs/reference/cli/supabase-vanity-subdomains-check-availability) command of the CLI to check if your desired subdomain is available for use:```bash-supabase vanity-subdomains --project-ref foobarbaz check-availability --desired-subdomain my-example-brand --experimental+supabase vanity-subdomains --project-ref abcdefghijklmnopqrst check-availability --desired-subdomain my-example-brand --experimental```-### Activate a subdomain+### Prepare to activate the subdomain-Once you've chosen an available subdomain, you can reconfigure your Supabase project to start serving traffic on the vanity subdomain (`my-example-brand.supabase.co`).-The auth service, in particular, will no longer work with the original URL (`foobarbaz.supabase.co`).-As such, it is recommended that you schedule a downtime window of 20-30 minutes, depending on the complexity of your project, to update all the services that need to know about your vanity subdomain:+Before you activate your vanity subdomain, prepare your applications and integrations for the subdomain change:-- any client code (e.g., frontends, mobile apps)-- any OAuth providers (e.g., Google, GitHub)+- The project's Supabase domain remains active and will not go away.+ - You do not need to change the Supabase URL in your applications immediately or at once.+ - You can use it interchangeably with the custom domain.+- Supabase Auth will use the subdomain immediately once activated.+ - OAuth flows will advertize the subdomain as a callback URL.+ - SAML will use the subdomain instead. This means that the `EntityID` of your project has changed, and this may cause SAML with existing identity providers to stop working.-The `activate` subcommand can be used to initiate the activation:+To prevent issues for your users, make sure you have gone through these steps:++1. Go through all of your Supabase OAuth providers:+ - In the provider's developer console (not in the Supabase dashboard!), find the OAuth application and add the subdomain Supabase Auth callback URL **in addition to the Supabase project URL.** Example:+ - `https://abcdefghijklmnopqrst.supabase.co/auth/v1/callback` **and**+ - `https://my-example-brand.supabase.co/auth/v1/callback`+ - [Sign in with Twitter](/docs/guides/auth/social-login/auth-twitter) uses cookies bound to the project's domain. In this case make sure your frontend code uses the subdomain instead of the default project's domain.+2. Go through all of your SAML identity providers:+ - You will need to reach out via email to all of your existing identity providers and ask them to update the metadata for the SAML application (your project). Use `https://example-brand.supabase.co/auth/v1/...` instead of `https://abcdefghijklmnopqrst.supabase.co/auth/v1/callback`.+ - Once these changes are made, SAML Single Sign-On will likely stop working until the domain is activated. Plan for this ahead of time.++### Activate a subdomain++Once you've chosen an available subdomain and have done all the necessary preparations for it, you can reconfigure your Supabase project to start using it.++Use the [`vanity-subdomains activate`](/docs/reference/cli/supabase-vanity-subdomains-activate) command to activate and claim your subdomain:```bash-supabase vanity-subdomains --project-ref fwmssjhjgszhnavvqxnt activate --desired-subdomain my-example-subdomain --experimental+supabase vanity-subdomains --project-ref abcdefghijklmnopqrst activate --desired-subdomain my-example-brand```-## Remove a vanity subdomain+If you wish to use the new domain in client code, you can set it up like so:-If you have a vanity subdomain (`my-example-brand.supabase.co`) set up for your Supabase project (ref `foobarbaz`, with assigned endpoints at `foobarbaz.supabase.co`), and would like to go back to using the Supabase-provisioned endpoints (`foobarbaz.supabase.co`), you can use the `delete` subcommand:+```js+import { createClient } from '@supabase/supabase-js'-```bash-supabase vanity-subdomains delete --project-ref foobarbaz --experimental+// Use a custom domain as the supabase URL+const supabase = createClient('https://my-example-brand.supabase.co', 'public-anon-key')```-As with the final activation stage of the process for setting up a vanity subdomain, you'll need to update any references in your client code and OAuth providers from the vanity subdomain to the Supabase-provisioned endpoints.+When using [Sign in with Twitter](/docs/guides/auth/social-login/auth-twitter) make sure your frontend code is using the subdomain only.-## Limitations+### Remove a vanity subdomain-- A Supabase project can—at this time—use either a Custom Domain or a Vanity Subdomain, but not both.-- Some authentication flows like Sign-in with Twitter set cookies to track the progress of the flow. Make sure you use only one domain in your frontend application for this reason. Mixing calls to the Supabase domain `foobarbaz.supabase.co` and your custom domain could cause those flows to stop working due to the [Same Origin Policy](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy) enforced on cookies by the browser.+Removing a subdomain may cause some issues when using Supabase Auth with OAuth or SAML. You may have to reverse the changes made in the _[Prepare to activate the subdomain](#prepare-to-activate-the-subdomain)_ step above.++Use the [`vanity-subdomains delete`](/docs/reference/cli/supabase-vanity-subdomains-delete) command of the CLI to remove the subdomain `my-example-brand.supabase.co` from your project.++```bash+supabase vanity-subdomains delete --project-ref abcdefghijklmnopqrst --experimental+```export const Page = ({ children }) => <Layout meta={meta} children={children} />