madhusudanbabar / k-domains

A simple module to manage multiple subdomains with just one project
https://www.npmjs.com/package/k-domains
MIT License
52 stars 8 forks source link

Dynamically map N subdomains to a folder #6

Open ErickPetru opened 3 years ago

ErickPetru commented 3 years ago

First of all, nice work done with this package.

Now, imagine this use case:

Is it possible right now? Or is it even viable with some work in this module code?

madhusudanbabar commented 3 years ago

From my understanding, I guess you want to have shared folders across multiples subdomains?

let's say you have 2 subdomains bestshoes and foodsite so your config file looks like this:

  export default {
    buildModules: [
      [ "k-domains", {
          subDomains: ["bestshoes", "foodsite" ],
          rootDomain: "root-domain" 
      }]
    ]
}

but even in this case, if you create a folder at pages and without adding it to the subdomains option in nuxt.config, it will be automatically mapped to all the subdomains.

consider this is your pages tree

|   
|─pages
|   ├───bestshoes
|   ├───foodsite
|   ├───root-domain
|   └───store // not added in the config file
|         ├───index.vue
|         └───offer.vue

so even in this version, the shared will be accessible from all the domains all the following will work:

and for getting the current subdomain, so yes I will add it in future releases, I'll export a variable for the current subdomain.

ErickPetru commented 3 years ago

Hi @madhusudanbabar, thanks for your reply. I think we're almost on it but not yet.

The deal is that I don't want a "store" route. The desired URLs would be:

I understand that I could put all those routes directly on pages folder and all would be available for every subdomain. But I can't do that, because the www.myplatform.com is the landing page of the platform and were the users create their own subdomains and configure it, so there would be files for the platform itself, not for each store. Can I have all store files mapped to each subdomain but not as a route of the subdomain?

Also, there are another deal: the names and the number of subdomains is unknow. A new user could arrive at the platform landing page and create a new account, registering a custom subdomain for their needs. So, is it possible to update on-the-fly the subDomains property on nuxt.config.js?

madhusudanbabar commented 3 years ago

sorry for the late reply, yes, I got it now, so in short, we've to map some folders to only selected subdomains with or w/o changing the route path, I mean including the store in the path or omitting it, both things are possible, I'll give it a try very soon, thanks

feikeq commented 3 years ago

是的,我也想要通过 * 泛域名指向pages里不同的文件夹

binumathew commented 2 years ago

I also have the same problem, its like a blog site, where my clients can choose different subdomain they want. can we use this module in that purpose? or only have static use case?

acidjazz commented 2 years ago

Came here looking to have *.domain.com go to something like /pages/_subdomain.vue - is this at all possible?

Kameecoding commented 2 years ago

@madhusudanbabar was the variable for exposing current subdomain ever added?