有没有人成功地篡改了一个Loopback-4 (lb4)应用程序?我设置了一个基于lb4的应用程序,并试图对其进行修改,但是尽管Docker似乎在运行该应用程序,但它并没有显示在我的本地主机上。
我所做的步骤:
但是,这个应用程序没有显示在http://localhost:3000上运行容器的输出:
trip@1.0.0预启动/usr/src/app npm运行构建 trip@1.0.0构建/usr/src/app lb-tsc es2017 --outDir trip@1.0.0 start /usr/src/app节点。 服务器正在http://127.0.0.1:3000上运行,尝试http://127.0.0.1:3000/ping
编辑
为了保存这个问题,这里粘贴了回购中的相关代码(步骤2),
// index.js
const application = require('./dist');
module.exports = application;
if (require.main === module) {
// Run the application
const config = {
rest: {
port: +process.env.PORT || 3000,
host: process.env.HOST || 'localhost',
openApiSpec: {
// useful when used with OASGraph to locate your application
setServersFromRequest: true,
},
},
};
application.main(config).catch(err => {
console.error('Cannot start the application.', err);
process.exit(1);
});
}发布于 2018-12-13 14:38:01
如@Henry在注释中所建议的,在您的index.js中,更改为使用
host: '0.0.0.0',要更多地了解localhost (127.0.0.1)和0.0.0.0之间的差异,请参见https://superuser.com/questions/949428/whats-the-difference-between-127-0-0-1-and-0-0-0-0
PS
最好在构建阶段使用npm run build,以便在运行时更快地启动。
https://stackoverflow.com/questions/53759617
复制相似问题