In loopback 3, we could set "restApiRoot" in the server config in order to prepend our api calls with some url (ie '/api') Is there some sort of way to do this in loopback 4? The documentation for the bundled REST server seems to have a port/protocol option, but nothing about api root.
The ability to configure REST API root path will be released in the next version of LoopBack 4, hopefully in the next few days.
The pull request: https://github.com/strongloop/loopback-next/pull/2097
Cross-posting from the documentation:
Sometime it's desirable to expose REST endpoints using a base path, such as
/api
. The base path can be set as part of the RestServer configuration.
const app = new RestApplication({
rest: {
basePath: '/api',
},
});
The RestApplication
and RestServer
both provide a basePath()
API:
const app: RestApplication;
// ...
app.basePath('/api');
With the basePath
, all REST APIs and static assets are served on URLs starting
with the base path.