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.
Asked
Active
Viewed 1,064 times
2
-
Did you find a way for it. I had the same query and about to ask question... – VISHAL DAGA Dec 03 '18 at 13:26
-
No I didn't @VISHALDAGA. Ended up reverting to loopback 3 until lb4 is feature equivalent. – JTG Dec 03 '18 at 21:21
1 Answers
7
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.

Miroslav Bajtoš
- 10,667
- 1
- 41
- 99