Dynamic subdomains

Hi, I would like to setup custom subdomain to act like a slug, something like: [slug].mysite.com. I thought of using nginx that reverse proxy that will swap the subdomain to the slug in the background. So something like this: subdomain.mysite.com/hello -> mysite.com/subdomain/hello. Do you know any better method to achieve the same result?
11 Replies
Neto
Neto2y ago
You should check a subtenant setup Will depend on the tech being used But the core idea is setting up a subtenancy
venus
venusOP2y ago
Okay, I will take a look on that. Do you have any resource about it? The setup is: NodeJS as the API and Next.js on client.
Neto
Neto2y ago
you can check vercel guide on multitenancy for that
Neto
Neto2y ago
Vercel Documentation
How to Build a Multi-Tenant App with Custom Domains Using Next.js
Create a full-stack application with multi-tenancy and custom domain support using Next.js, Prisma, PlanetScale, and Tailwind CSS.
Neto
Neto2y ago
or something like
venus
venusOP2y ago
Thanks, I would prefer the non vercel one, since I am going to have it all in one Docker container (or for now its the goal). But yeah, thank you.
Neto
Neto2y ago
gl
venus
venusOP2y ago
thanks! one more thing, those blogs are talking about different domains whereas i want tot start with subdomains first, does the pattern apply the same?
Neto
Neto2y ago
there are two parts from it one is next accepting subdomains and the node api accepting the info in a valid way from the next you should handle them separately next able to correctly render with the subdomain the api accepting parameters to indicate the subdomain related to that such as domain: ctx.req.headers.host, from this article
shaaah
shaaah2y ago
So you basically want to redirect the url from So something like this: subdomain.mysite.com/hello to this => mysite.com/subdomain/hello. ?
Want results from more Discord servers?
Add your server