The website I built with nodejs express is under route /pc, the mobile website is under /m, and then api data requests are under route /api
For example, the domain name of www.xxx.com points to the root directory/then www.xxx.com/pc is the website and www.xxx.com/m is the mobile website, where ajax request data is under the route to /api
Now I want to make sure that www.xxx.com is a pc website pointing directly to the /pc directory, visiting www.xxx.com is a pc website, not the previous path of www.xxx.com/pc. Similarly, m.xxx.com pointing to the /m directory is a mobile website.
There is a problem that api cannot be accessed, because the data route of ajax request when accessing www.xxx.com is /pc/api path, which is not /api
Can you tell me how nginx can be configured to meet this requirement? I don’t want to set up a domain name for api alone, such as setting up a api.xxx.com alone, because this is not a domain and it is very troublesome to cross domains.
Just write a location and deal with /api first.