Closed jariaz closed 10 months ago
Yes, this new version supports dynamic tenants by subdomains or using custom domains. There is some advantages for this new version, but it also comes with cons, such as: all tenants have to share the same layout, if we need to customize for some specific tenant we need to use conditional views..
For the previous version, it's something like multiple sites. Each route page folder can have a totally different view layout.
To support that case, it's not difficult, but I'm thinking of keeping 2 different versions or support them all in a single package.
Do you have any recommendation?
Yes, this new version supports dynamic tenants by subdomains or using custom domains.
Where or how is this configured? I didn't see an example in the playground. But in the example site I can see you devteam.nuxtdev.xyz & codenewbieteam.nuxtdev.xyz setup.
but it also comes with cons, such as: all tenants have to share the same layout
This might be okay for me, as I use a single layout but different pages/templates.
For the previous version, it's something like multiple sites. Each route page folder can have a totally different view layout. To support that case, it's not difficult, but I'm thinking of keeping 2 different versions or support them all in a single package. Do you have any recommendation
It would be nice if we had the option, all in a single package. To make it a little easier to implement, maybe we can have a toggle for one or the other? Or if its easier, breaking it out into a separate package also works.
The tenant will be extracted from the domain by getting from request hostname, use this official composable useRequestURL
For example when user requests: https://banana.nuxtdev.xyz -> the hostname will be banana.nuxtdev.xyz -> extract the banana string from the hostname, then use it for specifying tenant name. You can check the code here https://github.com/hieuhani/nuxt-multi-tenancy/blob/main/src/module.ts#L39
Just providing subdomain, we can have the tenant ID. The playground example is using dev.to API, and each dev.to organization will have an unique domain dynamically The playground is deployed to Vercel, and use wildcard domain: *.nuxtdev.xyz
I know this is an old thread but I have a question around local dev. How do I test with a custom domain locally? I added nuxtdev.local to my host file. I am able to see the website when i visit http://nuxtdev.local:3000 but If i try to visit a subdomain, it does not work.
So If i go to http://breezy.nuxtdev.local:3000, nothing loads. What do i need to configure to get it to work locally? @hieuhani
P.S I really appreciate this module. Thanks
I know this is an old thread but I have a question around local dev. How do I test with a custom domain locally? I added nuxtdev.local to my host file. I am able to see the website when i visit http://nuxtdev.local:3000 but If i try to visit a subdomain, it does not work.
So If i go to http://breezy.nuxtdev.local:3000, nothing loads. What do i need to configure to get it to work locally? @hieuhani
P.S I really appreciate this module. Thanks
Hi @BayBreezy, The easiest way to update is updating hosts file
Add your subdomain mapping there: for exxample:
127.0.0.1 breezy.nuxtdev.local
127.0.0.1 abc.nuxtdev.local
@hieuhani Thank you for the update. My best bet for now is to use localhost then.
I am not sure if you ever came across the issue of sharing cookies across subdomains? I was trying to share a cookie with no success. So after a user logs in at localhost:3000, navigating to mysite.localhost:3000 would clear the cookie.
P.S: This is not an issue with the module, just another web browser thing
For the previous version, it's something like multiple sites. Each route page folder can have a totally different view layout.
To support that case, it's not difficult, but I'm thinking of keeping 2 different versions or support them all in a single package.
How do you have multiple different folder supporting different subdomains?
Hi @Nisthar, we are discussing in this PR https://github.com/hieuhani/nuxt-multi-tenancy/pull/17 then this feature will be available soon after.
For the previous version, it's something like multiple sites. Each route page folder can have a totally different view layout. To support that case, it's not difficult, but I'm thinking of keeping 2 different versions or support them all in a single package.
How do you have multiple different folder supporting different subdomains?
Hi @Nisthar This feature has been added since version 1.2.0, please check
https://github.com/hieuhani/nuxt-multi-tenancy/pull/19 for the reference
Nice. I have been using some app router configs to do subdomain routing. I will give this a try.
Previously used the nuxt2 version of this app, and it works great! Not 100% sure I understand the documentation around setting a subdomain though? I didn't find an example of it in the 'playground'.