Multi tenant pages
Is it possible to create a wildcard and have a multi tenant pages project that displays different content based on subdomain?
16 Replies
GitHub
GitHub - vercel/platforms: A full-stack Next.js app with multi-tena...
A full-stack Next.js app with multi-tenancy and custom domain support. Built with Next.js App Router and the Vercel Domains API. - vercel/platforms
basically I'd like to host this project on cloudflare pages
nvm they use api there instead of wildcard dns i think
I also heard that "Cloudflare snippets" will be able to achieve it?
where does wildcard come into this? I don't see them mention it
yeah, they don't use wildcard in that project they use vercel domain api nvm
but a way to use wildcard and cloudflare pages together would be nice
you have two options really
1. Use normal Pages and Pages Custom Domains. Works fine until up to limit
(free 100, pro 250, biz 500, ent 500 but raisable). There's an api you can use to add custom domains.
2. Use CF for SaaS and a Worker as Origin proxying to pages, and then the CF for SaaS API. You'd have to pay for every request as a worker invocation though
for wildcards, you could do the same thing using a Worker to proxy requests and then just a wildcard route
snippets would just let you do that for free (the wildcard option)
I think if I use 1 domain and just tenant1.mydomain.com, tenant2.mydomain.com I can use DNS records then I will have 1000 records limit?
https://community.cloudflare.com/t/wildcard-domains-for-pages/477918/
if you use a wildcard and a worker proxy you have unlimited subdomains
I see, I wonder how expensive will that be
with CF SaaS
You'd have to pay for every request as a worker invocationdoesn't that mean i would be paying double? I already use workers for the app, I just want subdomains based routing
you use pages functions, you mean?
yeah
then yea you'd be paying for the worker invocation to handle the proxying to pages and then the pages function invocation if any. Standard billing is based off requests + cpu time so the proxied requests would have very little cpu time at least
and how would that compare price-wise, doing that vs using dns/domain api
you mean doing it via pages custom domains directly, with their hard limits?
yes
if i added e.g. 500 subdomains programmatically
vs having a worker proxy
https://community.cloudflare.com/t/wildcard-domains-for-pages/477918/ this mentions snippets will be able to act as a proxy too
then you wouldn't be paying for the worker invocation, just functions
yea I mentioned snippets in my message as well https://discord.com/channels/595317990191398933/1230191269787996171/1230209450170646579
I see, I guess I will start with DNS API first and then use snippets when they become available
thanks a lot