I'm unable to get the restApiRoot
variable to resolve when using it in middleware.json. I'm using Loopback 3. Here's my setup:
config.json
{
"restApiRoot": "/api"
}
middleware.json
"auth": {
"./middleware/order-auth": {
"paths": [
"${restApiRoot}/Orders"
]
}
},
If I replace ${restApiRoot}
with /api
then it works. I found this issue which sounds identical, but their resolution was to update loopback and loopback-boot back in 2016, and my versions are well beyond this. My middleware.json matches my version (3) docs.
I believe that loopback-boot performs variable substitution only when }
is the last character. See the source code in lib/plugin-base.js (loopback-boot version 3.x):
var DYNAMIC_CONFIG_PARAM = /\$\{(\w+)\}$/;
function getConfigVariable(app, param, useEnvVars) {
var configVariable = param;
var match = configVariable.match(DYNAMIC_CONFIG_PARAM);
// etc.