hieuhani / nuxt-multi-tenancy

Nuxt Multi Tenancy Module - multi-tenancy by sub domain for Nuxt application
https://techgoda.net/
MIT License
135 stars 14 forks source link

Using multiple domains instead of multiple #18

Closed thomasjwalsh closed 3 months ago

thomasjwalsh commented 3 months ago

I was wondering if there is a way to use nuxt-multi-tenancy with domains instead of subdomains. I'm more interested in using it like:

pages
    domainA
         ...
    domainB
         ...

Nuxt would then only serve pages from domainA for the domainA.com and domainB for the domainB.com. Is that possible?

Thanks for any info, Tom

hieuhani commented 3 months ago

Yes. I'm developing that feature. I will inform you once it's ready

thomasjwalsh commented 3 months ago

Nice, that's great news! Did you have a estimated time? If you need a hand I could potentially help too.

hieuhani commented 3 months ago

Thanks @thomasjwalsh

I will release the feature in the weekend, you can follow the PR https://github.com/hieuhani/nuxt-multi-tenancy/pull/19 I'm trying to figure out more edge cases and update the demo to complete 💪

hieuhani commented 3 months ago

Hi @thomasjwalsh, I've just published the version 1.2.0, please update and configure as bellow:

export default defineNuxtConfig({
  modules: ['nuxt-multi-tenancy'],
  multiTenancy: {
    tenantDynamicRoute: 'site',
    rootDomains: ["nuxtdev.local", "nuxtdev.xyz"],
    customDomains: {
      "domain-a.com": "domainA",
       "domain-B.com": "domainB"
    }
  },
})

Please let me know if you get any issue. Thanks,

thomasjwalsh commented 3 months ago

Hi @thomasjwalsh, I've just published the version 1.2.0, please update and configure as bellow:

export default defineNuxtConfig({
  modules: ['nuxt-multi-tenancy'],
  multiTenancy: {
    tenantDynamicRoute: 'site',
    rootDomains: ["nuxtdev.local", "nuxtdev.xyz"],
    customDomains: {
      "domain-a.com": "domainA",
       "domain-B.com": "domainB"
    }
  },
})

Please let me know if you get any issue. Thanks,

Hi @hieuhani, that's awesome! I'll give it go and let you know how.

conorseed commented 3 months ago

Hi @thomasjwalsh, I've just published the version 1.2.0, please update and configure as bellow:

export default defineNuxtConfig({
  modules: ['nuxt-multi-tenancy'],
  multiTenancy: {
    tenantDynamicRoute: 'site',
    rootDomains: ["nuxtdev.local", "nuxtdev.xyz"],
    customDomains: {
      "domain-a.com": "domainA",
       "domain-B.com": "domainB"
    }
  },
})

Please let me know if you get any issue. Thanks,

This looks super awesome!

Hopefully not abusing the thread, but I have a couple of questions for a use case for this feature: I'd like users to be able to add a custom domain themselves to their own created areas. With that in mind:

Or is this not how this module was intended to be used?

hieuhani commented 3 months ago

Hi @conorseed,

Would users just point their custom domain by A record to the same A record as the server?

Yes.

How might SSL certs be issued for those additional domains?

To me, because I control all my domains so I use Cloudflare SSL. You can write the automated script using Certbot to accomplish.

Is it possible to add/remove customDomains dynamically into the config? i.e. when a user adds or removes the domain from their settings?

I'm thinking, but I would want to propose some ideas to go with:

First, we need somewhere to store the user's custom domain mapping (can be persisted in the database). Then adding a new Nuxt middleware to determine the request domain to which tenant site. Or instead of Nuxt middleware you can use a proxy server.