Skip to content

Instantly share code, notes, and snippets.

@Gkiokan
Created January 16, 2022 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gkiokan/3b09ef7ebf26d294fd78e10c0dab389a to your computer and use it in GitHub Desktop.
Save Gkiokan/3b09ef7ebf26d294fd78e10c0dab389a to your computer and use it in GitHub Desktop.
Multiple Domain Routing with Vue-Router
const host = window.location.host;
const parts = host.split('.');
const domainLength = 3; // route1.example.com => domain length = 3
const router = () => {
let routes;
if (parts.length === (domainLength - 1) || parts[0] === 'www') {
routes = index;
} else if (parts[0] === 'route1') {
routes = route1;
} else if (parts[0] === 'route2') {
routes = route2;
} else {
// If you want to do something else just comment the line below
routes = index;
}
return routes;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment