DEV Community

Discussion on: Implement subdomains with VueJS.

Collapse
kp profile image
KP • Edited on

Thanks, the route.js file isn’t exposed in nuxt.js, however. There also is an nginx config to figure out here..

Thread Thread
arielmejiadev profile image
Ariel Mejia Author

I will take a look at Nuxt and probably this week I could have a solution, thanks for read the post :)

Thread Thread
kp profile image
KP

thank you, will wait :)

Thread Thread
juretopolak profile image
juretopolak

I'm also interested in the solution :)

Thread Thread
arielmejiadev profile image
Ariel Mejia Author

Hi, I research a about this in NuxtJS but there is no simple solution, in addition would need to add some config to the server nginx or apache to make it work, my best recommendation is to work with VueCLI and add the config that you need in the server or use a server side language to make it handle the subdomains for you, in Rails or Laravel this is pretty simple.

:( sorry if its not very helpful, but this is a little bit complicated, but if you find a way to handle this, please share your thoughts.

Thread Thread
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 Author

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