Join the Webstudio community

Updated 3 months ago

Automatically Publish Site To Multiple Domains And Provide Dns Records

At a glance

The community member is creating a multi-tenancy website where content is served using the domain name. They want to know if it's possible to automatically publish the same site to multiple domains and provide the users with the DNS records, or if the same DNS records will work for all. They don't want to manually add the domains in the builder, and an API solution would be fine, but they're concerned about the builder crashing if the site is mapped to 1000 distinct domains. Self-hosting is another option, but they prefer the standard way.

The community members discuss various approaches, such as using a single CNAME record with different TXT records, creating a dynamic page with a parameter to fetch the current user's data, and handling the domain check at the CMS backend API. The community members also discuss the challenges of using the system.origin variable, such as the difference between the builder and the live site, and the difficulty of testing.

The community members conclude that the approach of using a single CNAME and TXT record for multiple domains should work, and they discuss the purpose of the TXT record (to verify the domain ownership when Cloudflare is used as a proxy). However, there is no explicitly marked answer in the comments.

Useful resources
I am creating a multi-tenancy website (content is served using the domain name). Is it possible to automatically publish the same site to multiple domains and provide the user with the DNS records? Or, will the same DNS records work for all.

Manually adding in the builder wouldn't work. An API solution would be fine but I hope the builder doesn't crash if the site is mapped to say 1000 distinct domains

Self-hosting is another option, but I would prefer the standard way.
J
S
20 comments
Not sure I totally follow, but you can add multiple domains to your one site. They would use the same CNAME record but different TXT records.

That said, I feel like this isn't a good setup. I would go for multiple sites. In the future I think we'll have a way to share a design system between the projects.

Question, what do you expect to happen when someone goes to customerA.com and somebody else goes to customerB.com?
Hi john, i am using the resource element to get the data ... so customerA.com would get different data from customerB.com

I would like to use just one CNAME and one TXT record (if needed) .... and ask say 1000 customers just configure it on their DNS

Basically a resume website ... for 1000s of candidates

I dont want to add 1000 domains to the project ... if that makes sense ..

Hope I've been able to explain
To make this the most manageable, I would create a dynamic page with a parameter like ":user" that would dynamically fetch the current user's data.

It would be mywebsite.com/resumes/:user (just the general structure).

If you were to have a unique domain name and 1000's of customers, the logic would get unmaintainable. Essentially you'd need to have 1000 conditions checking the system.origin variable and comparing it to some value then fetching the proper slug/id from your CMS
oh actually the domains need to be different ... so ... cv.john.com ... cv.jack.com

i'm handling the domain check at the CMS backend api
curious how you are handling that at the cms backend?
just using the system.origin
Attachment
CleanShot_2024-09-08_at_21.39.17.png
the backend uses it to process the response
so you send system.origin to the backend? What CMS are you using that you can apply logic on that?
correct ... i'm developing me own CMS πŸ˜„
from the ground up?? why not use something already made? now you really have me interested lol
and jfyi using system origin is going to pose at least two problems:

  1. system.origin in builder and live site will be different
  2. system.origin can't be changed to my knowledge so it'll be difficult to test in the builder making the publishing to the live site the only real test (I suppose until this is done https://github.com/orgs/webstudio-is/projects/11?pane=issue&itemId=44511008)
i've tested it ... cv.jack.com is being passed correctly

i think i can just self-host and make it work if it comes to that
it will get passed correctly, yes. I'm saying that in the builder, system.origin will use the internal wstd.io domain and when published it'll use whatever hostname the user is on
yep .... my backend takes care of the check πŸ˜„
I think this will work then. As for domain, I need to get clarification on what the txt record does (I'm assuming some sort of verification). But the CNAME is the same so at least there is that
thx ... if that can be verification can be bypassed ... i should be good

will share the project soon!
checking... will report back with an answer
Ah so TXT is there because Cloudflare obscures CNAME records when behind the Proxy so TXT is mandatory to verify it
can the TXT be reused?

here ... the cv site ... eating my own dog food πŸ˜„

https://cv.notion.lol/
nice site! I don't believe it can be reused
Add a reply
Sign up and join the conversation on Discord