The vue-router documentation does not address this topic.
Perhaps my expectation that vue-router could handle this illustrates a fundamental misunderstanding of mine of how subdomains operate.
Could this be handled by vue-router, and if so, how, and if not, why not?
I had faced this same problem while setting up multiple subdomains for a client.
As @mzgajner mentioned it's true that it is not
directly
possible.But I would like to show you a simple hacky configuration which can help you setup your Vue.js application work on multiple subdomains.
You can use
window.location
in javascript or HTML'sanchor tag
to redirect your app on your subdomain. And then setup your vue-router to handle new routes.I've made this GitHub repo which runs on 3 different subdomains.
In this GitHub repo, look at this file. It shows a simple configuration to setup different routes for different subdomains.
Hope this helps everyone!!!
Nope, it's not possible.
vue-router
uses history.pushState, which doesn't allow you to change the origin. Quote from the docs:In other words -
vue-router
is a client-side router and you can't change the subdomain on the client-side (in the browser) without reloading the page.