How to handle custom domain in website builder?

Hi everyone,

I’m trying to build a website builder (that will generate static websites at the beginning).

I don’t know how to handle the situation when I need to allow customers to use their own domain.

I did a brainstorm and here is my solution:

  1. Generate their static website (html, css, js) into a folder on my server
  2. When customer enters the domain in my website builder tool => Tell them to point the domain to my server
  3. Then write a command to automatically generate virtual host/server block for each of those domains, and point to the location of static files (html, css, js)

I think that kind of approach is quite wrong (I don’t know why but I just feel wrong).

Can you please tell me what is the approach that website builders like Shopify did this?

Thank you very much