How does nginx set up the mobile website api configuration?

  node.js, question

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 points to the root directory/then is the website and is the mobile website, where ajax request data is under the route to /api

Now I want to make sure that is a pc website pointing directly to the /pc directory, visiting is a pc website, not the previous path of Similarly, 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 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 alone, because this is not a domain and it is very troublesome to cross domains.

Just write a location and deal with /api first.