Giter Club home page Giter Club logo

k-domains's People

Contributors

madhusudanbabar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

k-domains's Issues

Dynamically map N subdomains to a folder

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?

Disable redirect to rootdomain if subdomain does not exist

It would be very nice if there was an optional flag disabling the check:
if the subdomain is not in the list of user provided domains, set the rootdirectory to root - domain given by the user
This way, when a subdomain does not exist, it would be redirected to the 404 page.

Cannot read property 'substr' of undefined

Version:
1.2.5

Config:

buildModules: [
    [ 'k-domains', { subDomains: [ 'api' ], rootDomain: 'root' } ],
    [ '@nuxtjs/router', { keepDefaultRouter: true } ]
  ]

Layout:

/pages
  /api
    index.vue
    api.pug
    api.styl
    api.ts
  /root
    index.vue
    /login
      index.vue
      login.pug
      login.styl
      login.ts
    /index
      index.pug
      index.styl
      index.ts

Error:

 ERROR  Cannot read property 'substr' of undefined 

  at server.js:1965:28
  at Array.map (<anonymous>)
  at createRouter (src/router.js:57:0)
  at router_createRouter (src/.nuxt/router.js:6:0)
  at createApp (src/.nuxt/index.js:69:0)
  at module.exports.__webpack_exports__.default (src/.nuxt/server.js:82:0)
  at node_modules/vue-server-renderer/build.prod.js:1:78608
  at new Promise (<anonymous>)
  at node_modules/vue-server-renderer/build.prod.js:1:78080
  at Object.renderToString (node_modules/vue-server-renderer/build.prod.js:1:81615)

I attached a console.log to route.path and route.name (line 57 on router.js) and this is what the output was:

/api
api
/api/api
api-api
/root
undefined
/root/login
root-login
/root/login/login
root-login-login

Possible Solution:
(I made this change manually to my setup and it made it work)
change this:

return {
  ...route,
  path: route.path.substr(routesDirectory.length + 1) || "/",
  name: route.name.substr(routesDirectory.length + 1) || "index"
}

to this: (add optional chaining)

return {
  ...route,
  path: route.path?.substr(routesDirectory.length + 1) || "/",
  name: route.name?.substr(routesDirectory.length + 1) || "index"
}

Can't reexport the named export 'XXX' from non EcmaScript module

After following the tutorial (npm i k-domains @nuxtjs/router), and applying the change to the nuxt config file and the pages directory, every page gives this error multiple times:

 ERROR  in ./node_modules/@nuxtjs/composition-api/dist/runtime/index.mjs                                                                                                                                                                                   friendly-errors 17:20:48  

Can't reexport the named export 'watchEffect' from non EcmaScript module (only default export is available)                                                                                                                                                friendly-errors 17:20:48  
                                                                                                                                                                                                                                                           friendly-errors 17:20:48  

 ERROR  in ./node_modules/@nuxtjs/composition-api/dist/runtime/index.mjs                                                                                                                                                                                   friendly-errors 17:20:48  

Can't reexport the named export 'watchPostEffect' from non EcmaScript module (only default export is available)                                                                                                                                            friendly-errors 17:20:48  
                                                                                                                                                                                                                                                           friendly-errors 17:20:48  

 ERROR  in ./node_modules/@nuxtjs/composition-api/dist/runtime/index.mjs                                                                                                                                                                                   friendly-errors 17:20:48  

Can't reexport the named export 'watchSyncEffect' from non EcmaScript module (only default export is available)     

go to subdomain nuxt-link

Hello, how can I go to a subdomain using a nuxt-link without knowing whether I am on a localhost or on a server?More precisely, how can I switch from a domain to a subdomain what write - go to sub

Allow change to default "subdomain not found" behaviour

Currently, k-domains redirects to the root domain if the domain specified is not found.
// if the subdomain is not in the list of user provided domains, set the rootdirectory to root - domain given by the user
Would it be possible to add an option to change this behaviour to just redirect to the error 404 page?

Ps. Thanks for leaving in at least some comments, I don't understand why large scale projects never have those. It made it lots easier for me to understand.

Nuxt-18n support?

Hello, how can I make k-domains work with nuxt-18n? I tried and the switchLocalePath seems to be broken and on compile some warnings were thrown

WARN  [vue-router] Route with name '__id___id' does not exist

WARN  [vue-router] Route with name 'index___id' does not exist 

WARN  [vue-router] Route with name '__id___en' does not exist                                                                                                                                                                                                                                                         

WARN  [vue-router] Route with name '__id___id' does not exist   

Doesn't seem to work for me

Hi there,

here's my nuxt.config buildModules section:

 buildModules: [
    [
      'k-domains',
      {
        subDomains: ['app'],
        rootDomain: 'root',
      },
    ],
    [
      '@nuxtjs/router',
      {
        keepDefaultRouter: true, // this line is mandatory...
      },
    ],
  ],

and so I expect app.myDomain/ to render the index.vue inside my pages/app directory

similarly, I expect myDomain/ to render the index.vue inside my pages/root directory

Instead I get a This page could not be found nuxt error:
image

Am I missing something?

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.