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
You should check a subtenant setup
Will depend on the tech being used
But the core idea is setting up a subtenancy
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.
you can check vercel guide on multitenancy for that
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.
or something like
mikealche
Mike Alche
How to create a Multi-tenant application with Next.js and Prisma - ...
How to create a Multi-tenant application with Next.js and Prisma - software-development - Mike Alche
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.
gl
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?
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 articleSo you basically want to redirect the url from So something like this: subdomain.mysite.com/hello to this => mysite.com/subdomain/hello. ?