Bird
Raised Fist0
Denoframework~20 mins

Custom domains in Deno - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Deno Custom Domains Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
2:00remaining
What is the output when accessing a custom domain in Deno Deploy?

You have deployed a Deno application with a custom domain configured. The app returns a JSON response with {"message": "Hello from custom domain"}. What will the browser display when visiting the custom domain URL?

Deno
import { serve } from "https://deno.land/std@0.177.0/http/server.ts";

serve(() => new Response(JSON.stringify({ message: "Hello from custom domain" }), {
  headers: { "content-type": "application/json" },
}));
AThe browser shows a 404 Not Found error
BThe browser shows a JSON object: {"message": "Hello from custom domain"}
CThe browser shows a blank page with no content
DThe browser shows an HTML page with a welcome message
Attempts:
2 left
💡 Hint

Think about what the server sends as a response and how the browser displays JSON content.

📝 Syntax
intermediate
2:00remaining
Which code snippet correctly sets a custom domain in Deno Deploy configuration?

You want to configure a custom domain for your Deno Deploy project using the deno.json configuration file. Which snippet correctly sets the domain example.com?

A
{
  "deploy": {
    "domains": ["example.com"]
  }
}
B
{
  "deploy": {
    "domains": "example.com"
  }
}
C
{
  "customDomain": "example.com"
}
D
{
  "deploy": {
    "customDomain": ["example.com"]
  }
}
Attempts:
2 left
💡 Hint

Check the correct property name and data type for custom domains in the deploy config.

🔧 Debug
advanced
2:00remaining
Why does the custom domain fail to serve the Deno Deploy app?

You set up a custom domain for your Deno Deploy app, but visiting the domain shows a DNS error. What is the most likely cause?

AThe DNS records for the domain are not pointing to Deno Deploy's servers
BThe Deno Deploy app code has a syntax error causing it to crash
CThe custom domain is not added to the <code>deno.json</code> file
DThe app is missing an <code>index.html</code> file
Attempts:
2 left
💡 Hint

Think about what DNS does and what must be configured for a domain to resolve.

❓ state_output
advanced
2:00remaining
What is the value of the Host header when accessing a Deno Deploy app via a custom domain?

You access your Deno Deploy app using the custom domain myapp.example.com. What will be the value of the Host header in the incoming HTTP request to your app?

Adeploy.deno.com
Bdeno.com
Clocalhost
Dmyapp.example.com
Attempts:
2 left
💡 Hint

The Host header reflects the domain name used in the browser URL.

🧠 Conceptual
expert
2:00remaining
How does Deno Deploy handle HTTPS certificates for custom domains?

When you add a custom domain to your Deno Deploy project, how does Deno Deploy manage HTTPS certificates for secure connections?

AHTTPS certificates are provided only if you configure a paid plan manually
BYou must manually upload your own HTTPS certificates to Deno Deploy for the custom domain
CDeno Deploy automatically provisions and renews HTTPS certificates via Let's Encrypt for the custom domain
DDeno Deploy does not support HTTPS on custom domains; you must use HTTP only
Attempts:
2 left
💡 Hint

Consider how modern hosting platforms simplify HTTPS setup for custom domains.

Practice

(1/5)
1. What is the main purpose of setting a custom domain in a Deno server?
easy
A. To increase the server's processing speed
B. To use your own website name instead of a generic address
C. To automatically update the server software
D. To enable debugging features in Deno

Solution

  1. Step 1: Understand what a custom domain is

    A custom domain lets you use a personalized website name instead of a default or generic address.
  2. Step 2: Identify the purpose in Deno context

    Setting a custom domain in Deno allows your server to respond to your own website name, making it easier for users to find your site.
  3. Final Answer:

    To use your own website name instead of a generic address -> Option B
  4. Quick Check:

    Custom domain = personalized website name [OK]
Hint: Custom domain means your own website name, not generic [OK]
Common Mistakes:
  • Confusing custom domain with server speed
  • Thinking it updates software automatically
  • Assuming it enables debugging
2. Which of the following is the correct way to set a custom domain hostname in Deno's serve function?
easy
A. serve({ url: "mydomain.com" })
B. serve({ domain: "mydomain.com" })
C. serve({ hostname: "mydomain.com" })
D. serve({ host: "mydomain.com" })

Solution

  1. Step 1: Recall Deno serve options

    The serve function accepts an option called hostname to set the domain name.
  2. Step 2: Match the correct option key

    Only hostname is the correct key; others like domain, host, or url are invalid here.
  3. Final Answer:

    serve({ hostname: "mydomain.com" }) -> Option C
  4. Quick Check:

    Use hostname option in serve [OK]
Hint: Use 'hostname' option exactly in serve function [OK]
Common Mistakes:
  • Using 'domain' or 'host' instead of 'hostname'
  • Passing the domain as a string without key
  • Confusing 'url' with hostname option
3. Given the following code snippet, what will be the hostname the server listens on?
import { serve } from "https://deno.land/std/http/server.ts";
serve(() => new Response("Hello"), { hostname: "example.com" });
medium
A. The server will throw a runtime error
B. The server listens on localhost only
C. The server listens on all IP addresses
D. The server listens on example.com domain

Solution

  1. Step 1: Examine the hostname option

    The code sets hostname: "example.com" in the serve options.
  2. Step 2: Understand hostname resolution and binding

    Deno resolves "example.com" to a public IP (93.184.216.34) via DNS. If the IP is assigned to the local machine's network interfaces, the server binds successfully and listens on that domain. Otherwise, it will throw a runtime error.
  3. Step 3: Typical behavior

    Usually, binding to a hostname that resolves to a public IP not assigned locally will fail. But if the environment is configured properly (e.g., hosts file or network interface), it can succeed.
  4. Final Answer:

    The server listens on example.com domain -> Option D
  5. Quick Check:

    Hostname option sets server listening domain [OK]
Hint: Hostname option sets server listening domain [OK]
Common Mistakes:
  • Thinking server listens directly on domain without IP resolution
  • Assuming default localhost behavior
  • Believing it falls back to all IPs
4. You set hostname: "mydomain.com" in your Deno server but users cannot reach your site. What is the most likely cause?
medium
A. You forgot to point your domain's DNS to your server's IP address
B. The serve function does not support custom domains
C. You must use host instead of hostname
D. Deno requires a special flag to enable custom domains

Solution

  1. Step 1: Verify Deno serve supports hostname

    Deno's serve supports hostname option, so options B, C, and D are incorrect.
  2. Step 2: Check DNS setup

    If users cannot reach the site, the domain's DNS likely does not point to the server's IP, blocking access.
  3. Final Answer:

    You forgot to point your domain's DNS to your server's IP address -> Option A
  4. Quick Check:

    DNS must point domain to server IP [OK]
Hint: Check DNS points domain to server IP if unreachable [OK]
Common Mistakes:
  • Assuming serve lacks custom domain support
  • Using wrong option key like 'host'
  • Thinking Deno needs special flags for domains
5. You want to serve your Deno app on your custom domain "myapp.com" and also allow access via localhost for testing. Which setup correctly supports both?
hard
A. Set hostname to "0.0.0.0" to listen on all interfaces including domain and localhost
B. Set hostname to "myapp.com, localhost" in a single serve call
C. Run two servers: one with hostname "myapp.com" and one with hostname "localhost"
D. Use hostname "localhost" and rely on DNS to redirect "myapp.com"

Solution

  1. Step 1: Understand hostname options

    Setting hostname to "0.0.0.0" makes the server listen on all network interfaces, including your domain and localhost.
  2. Step 2: Evaluate other options

    Run two servers: one with hostname "myapp.com" and one with hostname "localhost" requires two servers which is inefficient; Set hostname to "myapp.com, localhost" in a single serve call is invalid syntax; Use hostname "localhost" and rely on DNS to redirect "myapp.com" relies on DNS redirect which does not work for localhost access.
  3. Final Answer:

    Set hostname to "0.0.0.0" to listen on all interfaces including domain and localhost -> Option A
  4. Quick Check:

    Use 0.0.0.0 to listen on all interfaces [OK]
Hint: Use 0.0.0.0 hostname to serve domain and localhost [OK]
Common Mistakes:
  • Trying to list multiple hostnames in one serve call
  • Running multiple servers unnecessarily
  • Relying on DNS to redirect localhost
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard