Is there any way for nuxt to render different pages according to url?

A requirement of our company is to set different subdomains for different modules. For example, the home page for renting is rent.test.com, and the home page for buying a house is sale.test.com, but for a nuxt project, the root path / can only correspond to one component, either a rental component or a purchase component. Can this situation be solved?

at first, I thought that through redirection, there is a problem, that is, if you jump to path: "/" through nuxt-link in the nuxt project, you still can"t display different pages according to the domain name.

what may come to mind at the moment is whether nuxt can dynamically render components by judging the domain name (the components here are components in the pages directory that support asyncData)


Yes, write:

in the middleware
const host = process.server
    ? context.req.headers['host']
    : window.location.host;
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8908f-46cf8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8908f-46cf8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?