DEV Community

Discussion on: Implement subdomains with VueJS.

 
juretopolak profile image
juretopolak

I'm researching the options to build a kind of multi-tenant app, where each user would have own subdomain.
From DNS standpoint it's easy to create a wildcard record that points all subdomains to the same ip address. From the server standpoint, I also have an idea on how to point all traffic to subdomains in the same directory where would be nuxt app.
I was hoping that nuxt router has some kind of support, to get domain and its parts from this.$route but it has not.
So I guess the only solution would be to extract parts of a domain with plain JS like this:
const parts = window.location.host.split('.') and get subdomain value from the array.
I just don't know yet what would be the best way to make this value available globally. Maybe to store it in Vuex?

Thread Thread
 
arielmejiadev profile image
Ariel Mejia

In docs there is no support for any like this in the routes, I dont understand how can it suppose to work because even if you get the right config on the server I do not understand how to apply all the changes and it what layer of the app it would work, for me its easy to understand how it works on server side languages, sorry