Config domains automatic

I am trying to build an MVP where users who register on my system can either input a domain or choose a subdomain of my main domain. All these domains created on my VPS should be pointed to the same Node.js application running. For example:

A user signs up and inputs “” as their domain. My system will configure this domain on Cloudflare, and then the user needs to configure it on my VPS so that this domain points to the existing Node.js application. The same applies to subdomains.

I’ve seen that something can be done using aliases on the main domain through CyberPanel, but I need this to be done automatically.