Created
January 16, 2022 10:47
-
-
Save Gkiokan/3b09ef7ebf26d294fd78e10c0dab389a to your computer and use it in GitHub Desktop.
Multiple Domain Routing with Vue-Router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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