我已经在本地构建了一个strongloop环回API服务器,一切正常但是当我将它上传到我的远程服务器时,SLC RUN命令运行正常(我可以在终端中看到它实际上创建了我的测试在同一服务器上的MySQL数据库中的模型)但是我无法访问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 install loopback-explorer)...
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);
});
};
答案 0 :(得分:0)
端口是问题,请参阅问题中的评论。闭合。