connecteev
1 month ago

Nuxt subdomain routing

Posted 1 month ago by connecteev

I'm trying to implement subdomain routing in Nuxt. This is what I need to do:

/pages/username/index.vue:
username1.mydomain.com (this page should display "hello, i am username1")
username2.mydomain.com (this page should display "hello, i am username2")
username3.mydomain.com (this page should display "hello, i am username3")
username4.mydomain.com (this page should display "hello, i am username4")
and so on

/pages/username/content.vue
username1.mydomain.com/content (this page should display "content by username1")
username2.mydomain.com/content (this page should display "content by username2")
username3.mydomain.com/content (this page should display "content by username3")
username4.mydomain.com/content (this page should display "content by username4")
and so on

I found this link (have yet to make it work) but it uses @Nuxtjs/router to (i think) override vue-router - wondering if there's a better way, I really like nuxt's ability to "create a page and you dont need to define the route" approach. Is there a way to do this in nuxt, ideally without vue-router, keeping the nuxt default page / routing behavior?

Please sign in or create an account to participate in this conversation.