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.
答案 0 :(得分:1)
我相信,只有当}
是最后一个字符时,loopback-boot才会执行变量替换。请参见lib/plugin-base.js(回送引导版本3.x)中的源代码:
var DYNAMIC_CONFIG_PARAM = /\$\{(\w+)\}$/;
function getConfigVariable(app, param, useEnvVars) {
var configVariable = param;
var match = configVariable.match(DYNAMIC_CONFIG_PARAM);
// etc.