在远程服务器上时不显示强环路环回资源管理器

Strongloop Loopback explorer not showing when on remote server

本文关键字:环路 资源管理器 显示 服务器      更新时间:2023-09-26

我已经在本地构建了一个强循环环回 API 服务器,一切正常,但是当我将其上传到我的远程服务器时,SLC RUN 命令运行良好(我可以在终端中看到它实际上在同一台服务器上的 MySQL db 中创建我的测试模型),但我无法访问 example.com/explorer 页面以查看 API...我是否需要以不同的方式配置某些内容才能使其在远程服务器上工作?

我将端口从 3000 更改为 3001。这是我在服务器文件中的config.json文件。

{
"restApiRoot": "/api",
"host": "www.example.com",
"port": 3001,
"remoting": {
"context": {
  "enableHttpContext": false
},
"rest": {
  "normalizeHttpPath": false,
  "xml": false
},
"json": {
  "strict": false,
  "limit": "100kb"
},
"urlencoded": {
  "extended": true,
  "limit": "100kb"
},
"cors": {
  "origin": true,
  "credentials": true
},
"errorHandler": {
  "disableStackTrace": false
}
 }
}

和引导目录中的资源管理器文件(是的,我确实运行了 npm 安装环回资源管理器)...

module.exports = function mountLoopBackExplorer(server) {
var explorer;
try {
explorer = require('loopback-explorer');
 } catch(err) {
// Print the message only when the app was started via `server.listen()`.
// Do not print any message when the project is used as a component.
server.once('started', function(baseUrl) {
  console.log(
    'Run `npm install loopback-explorer` to enable the LoopBack explorer'
  );
});
 return;
}
var restApiRoot = server.get('restApiRoot');
var explorerApp = explorer(server, { basePath: restApiRoot });
server.use('/explorer', explorerApp);
server.once('started', function() {
var baseUrl = server.get('url').replace(/'/$/, '');
// express 4.x (loopback 2.x) uses `mountpath`
// express 3.x (loopback 1.x) uses `route`
var explorerPath = explorerApp.mountpath || explorerApp.route;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
});
};

端口是问题所在,请参阅问题中的注释。闭。