DEV Community

Cover image for Custom Domain Support in Creator Economy Platforms
Yoram Kornatzky
Yoram Kornatzky

Posted on • Updated on • Originally published at yoramkornatzky.com

Custom Domain Support in Creator Economy Platforms

Most creator platforms support two forms of custom domains: \

  • Subdomains - such as johndoe.platformX.com
  • Custom domain - such as platformX.johndoe.com

Describing the creator domain as part of the URL of the site, such as www.platformX.com/johndoe, is much less common.

If you are about to construct such a platform, you may wonder how complicated it is to build custom domain support.

It turns out it is straightforward.

It boils down to two things:

  1. The user doing setup in their domain registrar or website hosting company
  2. Routing in your platform

Domain Setup by User

You should instruct users to add appropriate DNS records in their domain registrar or hosting company. There are many examples of instructions in existing platforms that you can borrow.

The Transistor podcasting platform instructions that I recently used are excellent.

Routing in Platform

While I do not know which backend programming framework or language you use, the following in Laravel PHP is pretty generic and can be adapted to:

  • Any PHP framework
  • Express.js or any Node.js backend framework
  • Ruby on Rails
  • Java Spring Boot

Domains

Route::group(['domain' => '{subdomain}.{domain}.{tld}'], function(){

    Route::any('/', function($sub, $domain, $tld){
        return 'custom domain: ' .  
            $sub . '. ' . 
            $domain .  '. ' . 
            $tld;
    });

});
Enter fullscreen mode Exit fullscreen mode

Subdomain

Route::domain('{account}.example.com')->group(function () {
    Route::get('user/{id}', function ($account, $id) {
        //
    });
});
Enter fullscreen mode Exit fullscreen mode

Top comments (0)