Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically map N subdomains to a folder #6

Open
ErickPetru opened this issue Oct 10, 2020 · 7 comments
Open

Dynamically map N subdomains to a folder #6

ErickPetru opened this issue Oct 10, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@ErickPetru
Copy link

First of all, nice work done with this package.

Now, imagine this use case:

  • pages/index.vue is a hot site offering a complex software as a service platform, like an e-commerce for example, with a domain like myplatform.com.
  • pages/admin/*.vue let users of the platform create their own stores choosing any subdomain they like.
  • pages/store/*.vue all the stores use the same logic, so all the products, categories, cart, order, etc., will be components inside the generic store folder.
  • Any access to any subdomain should point to the pages/store folder, like bestshoes.myplatform.com or foodsite.myplatform.com. And for sure we'd need to be able to get the current subdomain to use it as a param form API requests, so we can get the right data for each store.

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

@madhusudanbabar
Copy link
Owner

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:

  • bestshoes.myplatform.com/store
  • bestshoes.myplatform.com/store/offer
  • foodsite.myplatform.com/store
  • foodsite.myplatform.com/store/offer

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

@madhusudanbabar madhusudanbabar added the enhancement New feature or request label Oct 12, 2020
@ErickPetru
Copy link
Author

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:

  • bestshoes.myplatform.com (index of the bestshoes e-commerce).
  • bestshoes.myplatform.com/cart (cart of bestshoes e-commerce).
  • foodsite.myplatform.com (index of the foodsite e-commerce).
  • foodsite.myplatform.com/cart (cart of foodsite e-commerce).
  • And so on... These are just samples, all other routes (like product routes) should be available for both subdomains.

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
Copy link
Owner

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
Copy link

feikeq commented Mar 17, 2021

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

@binumathew
Copy link

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
Copy link

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

@Kameecoding
Copy link

Kameecoding commented Sep 23, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants