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.
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?
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
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
@arielmejiadev is there a way to implement subdomains in a laravel + nuxt.js stack? Please create a short follow up post :)
Well I suppose Nuxt has a route.js file to register and handle routes, so you can test a route like this:
You only need to identify where the VueRouter instance is export
Thanks, the route.js file isn’t exposed in nuxt.js, however. There also is an nginx config to figure out here..
I will take a look at Nuxt and probably this week I could have a solution, thanks for read the post :)
thank you, will wait :)
I'm also interested in the solution :)
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.
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?
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