Custom domains in Supabase - Time & Space Complexity
When setting up custom domains in Supabase, it's important to understand how the time to complete the setup grows as you add more domains.
We want to know how the number of domains affects the total operations needed to configure them.
Analyze the time complexity of adding multiple custom domains to a Supabase project.
// Example: Adding multiple custom domains
const domains = ['example1.com', 'example2.com', 'example3.com'];
for (const domain of domains) {
await supabase.functions.createCustomDomain({
domain: domain,
projectId: 'project-id'
});
}
This code adds each domain one by one to the Supabase project by calling the API for each domain.
Identify the API calls, resource provisioning, data transfers that repeat.
- Primary operation: API call to create a custom domain for each domain.
- How many times: Once per domain added.
Each new domain requires one API call, so the total calls grow directly with the number of domains.
| Input Size (n) | Approx. API Calls/Operations |
|---|---|
| 10 | 10 API calls |
| 100 | 100 API calls |
| 1000 | 1000 API calls |
Pattern observation: The number of operations grows in a straight line as you add more domains.
Time Complexity: O(n)
This means the time to add custom domains grows directly in proportion to how many domains you add.
[X] Wrong: "Adding multiple domains happens all at once, so time stays the same no matter how many domains."
[OK] Correct: Each domain requires a separate API call, so the total time increases with each additional domain.
Understanding how operations scale with input size helps you design efficient cloud setups and explain your reasoning clearly in interviews.
"What if the API allowed batch adding of multiple domains in one call? How would the time complexity change?"
Practice
Solution
Step 1: Understand what a custom domain is
A custom domain lets you use your own website address instead of a generic one provided by a service.Step 2: Relate to Supabase usage
In Supabase, setting a custom domain means your app uses your own URL, making it look professional and branded.Final Answer:
To use your own website address instead of a default Supabase URL -> Option DQuick Check:
Custom domain = Own website address [OK]
- Thinking it increases database size
- Confusing with performance features
- Assuming it creates user accounts
Solution
Step 1: Identify DNS record types for domain pointing
CNAME records are used to alias one domain name to another, commonly used to point custom domains to services.Step 2: Match with Supabase custom domain setup
Supabase requires a CNAME record to link your custom domain to their servers.Final Answer:
CNAME record -> Option AQuick Check:
Custom domain pointing uses CNAME [OK]
- Using MX record which is for email
- Using TXT record meant for verification
- Confusing SRV record with domain pointing
domain: "app.example.com"
records: [
{ type: "CNAME", value: "db.supabase.co" }
]What happens when a user visits
app.example.com?Solution
Step 1: Understand CNAME effect
The CNAME record points the domain to Supabase's hosting address, so requests go there.Step 2: Interpret user visit behavior
When visiting app.example.com, the browser connects to Supabase hosting serving the app, not the database interface or errors.Final Answer:
Their browser connects to Supabase hosting for the app -> Option BQuick Check:
CNAME directs browser to Supabase hosting [OK]
- Confusing database interface with hosting
- Assuming DNS error from correct CNAME
- Thinking email verification appears on visit
Solution
Step 1: Identify cause of browser security warnings
Security warnings usually happen when SSL (secure connection) is missing or invalid.Step 2: Relate to Supabase custom domain setup
Supabase requires enabling SSL for custom domains to avoid browser warnings.Final Answer:
You forgot to enable SSL for the custom domain -> Option CQuick Check:
Missing SSL causes browser security warnings [OK]
- Confusing MX record with SSL
- Thinking domain format causes security warning
- Assuming CNAME IP address is used instead of hostname
dashboard.myapp.com for your Supabase project. Which steps must you follow to ensure it works correctly and securely?Solution
Step 1: Purchase domain and configure DNS
First, buy your domain (dashboard.myapp.com) and add a CNAME record pointing to Supabase's domain to route traffic correctly.Step 2: Enable SSL for secure connections
Then, enable SSL in Supabase settings to secure the connection and avoid browser warnings.Final Answer:
Buy the domain, add a CNAME DNS record pointing to Supabase, then enable SSL in Supabase settings -> Option AQuick Check:
Domain + CNAME + SSL = Correct setup [OK]
- Using MX or TXT records incorrectly
- Skipping SSL causing security warnings
- Using A record instead of CNAME for Supabase
Ready to prove it?
Pass the test and this pattern moves unknown
