N
Nuxt3mo ago
Mirage

How to make Nuxt route a specific domain to a prefix?

Consider a normal Nuxt app that has pages under /pages/site/[site]/* . Those pages can be accessible like so example.com/site/foo/my-page-1 example.com/site/foo/my-page-2 etc. Now, I also want those pages to be accessible without a prefix when a specific domain is used. E.g. foo.com/my-page-1 should display the same page as exanple.com/site/foo/my-page-1 How to achieve this with Nuxt?
2 Replies
kapa.ai
kapa.ai3mo ago
Hi @Mirage. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I'm sorry, but the knowledge sources do not contain explicit information on how to route a specific domain to a prefix in Nuxt (e.g., mapping foo.com/my-page-1 to example.com/site/foo/my-page-1). The available documentation covers file-based routing, custom router options, and dynamic routes, but does not address domain-based routing or host-based route aliasing. This type of advanced routing typically involves server-level configuration (such as with a reverse proxy like Nginx or Apache) or custom middleware to detect the domain and rewrite the route accordingly. However, there is no direct guidance or example for this scenario in the provided Nuxt documentation or community answers. If you need to implement this, you may need to combine server configuration with custom Nuxt middleware, but the knowledge sources do not provide a Nuxt-specific solution for this use case. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@1368579779309207656> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?