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

Host based routing? #1611

Closed
mrinc opened this Issue Jul 17, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@mrinc
Copy link

mrinc commented Jul 17, 2017

What problem does this feature solve?

I have multiple sites that are based off the same SPA, content is just a bit different.
So instead of having 3 separate sites, I can just have a single one and route based on hostname.

  • it would just be a subdomain change so nothing major, but allowing certain routes' paths to be the same but act differently depending on the hostname.
    This would be helpful for maintenance purposes

What does the proposed API look like?

No idea yet... I am busy working on it, but wanted to get any input you guys may have?
Or maybe if there is a better way to do what I am trying to do?

@nickmessing

This comment has been minimized.

Copy link
Member

nickmessing commented Jul 17, 2017

@mrinc, considering that hostname never changes you can just:

import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'

const generateRoutes = () => {
  switch (location.hostname) {
    case 'google.com': {
      return [
        path: '/',
        component: Hello
      ]
    }
    case 'google.co.nz': {
      return [
        path: '/homepage',
        component: Hello
      ]
    }
  }
}

Vue.use(Router)

export default new Router({
  routes: generateRoutes()
})
@LinusBorg

This comment has been minimized.

Copy link
Member

LinusBorg commented Jul 18, 2017

Nick's suggestion should solve your problem. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment