Support for custom domains at DataHub Cloud

Support for custom domains at DataHub Cloud

Summary

  • Situation: Currently user sites are available at datahub.io domain, at /@{username}/{projectName}/... paths.
  • Problem: Some users, especially corporate clients, would like to use their own domain instead.
  • Appetite: 2-4h
  • Solution: mostly done, needs another app route @domain/[domain]/[[...slug]] and some middleware adjustments and testing

Situation

Currently user sites are available at datahub.io domain, at /@{username}/{projectName}/... paths.

Problem

Some users, especially corporate clients, would like to use their own domain instead.

Appetite

1 day

Solution

Dashboard UI part and logic related to custom domain configuration is already implemented and comes from the original vercel/platforms boilerplate.

High level overview

You bring your own domain (can be it's subdomain as well) and enter it in the dashboard.

../assets/Pasted image 20240311162101.png

After hitting "Save changes" the app will use Vercel API to set the domain in the Vercel's project:

../assets/Pasted image 20240311161914.png Then you'll see current domain registration status below the input field.

../assets/Pasted image 20240311161728.png

Then you need to set A or CNAME records at your custom domain's registrar. After doing this the information under the input field will change and show you if the configuration is now valid.

Domain resolution to correct app route

Proposed option: Option A.

Option A: separate app routes for single-site URLs and custom domains

Custom domain is routed to another app route in the middleware.ts file. So we'd end up having:

  • /[username]/[projectName]/[[...slug]] and
  • e.g. /@domain/[[...slug]]

Core, repeated logic in both routes will be imported from a shared module.

../assets/Pasted image 20240311153643.png

❌ Option B: single app route for single-site URLs and custom domains

Custom domain is resolved in the middleware.ts file to the corresponding username and projectName. Then, the request is "rewritten" to /[username]/[projectName]/[[...slug]] (URL stays the same, i.e. with custom domain, but the same app route is used to render both single-site URL and custom domain ones.)

Why not:

  • making a database call in the middleware can add latency to requests
  • resolving wikilinks so that they link to the custom domain will require awkward additional db call in the slug page to find out if the site has custom domains set

../assets/Pasted image 20240311153659.png

Rabbit holes

No-goes

  • Making custom domain a premium feature in some way For now, let's just ship. For future we probably want a way to switch option to set domain on/off for a given site/project so that it can be tied to pricing tier. But that's the future

© 2024 All rights reservedBuilt with Find, Share and Publish Quality Data with Datahub

Built with Find, Share and Publish Quality Data with DatahubFind, Share and Publish Quality Data with Datahub