3

I've built an strongloop loopback API server locally and everything worked fine but when I've uploaded it to my remote server the SLC RUN command runs fine (I can see it in terminal it actually created my test models in MySQL db on the same server) but yet I can't access the example.com/explorer page to see the APIs...do I need to configure something differently to have it work when it's on a remote server?

I changed the port from 3000 to 3001. Here is my config.json file in the server file.

{
"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
}
 }
}

and the explorer file in the boot directory (yes I did run the 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);
});
};
Jordan Kasper
  • 13,153
  • 3
  • 36
  • 55
Emmanuel Henri
  • 153
  • 3
  • 27
  • you mean example.com:3001/explorer right? (not example.com/explorer) or is there some proxy server passing through to your node instance? – pherris Dec 05 '14 at 17:04
  • yes sorry I mean example.com:3001/explorer...any ideas why I'm having this issue? – Emmanuel Henri Dec 05 '14 at 17:05
  • is that port open on the machine you are connecting to (http://stackoverflow.com/questions/9609130/quick-way-to-find-if-a-port-is-open-on-linux)? is it an EC2 instance? – pherris Dec 05 '14 at 17:22
  • Do you get any errors? Stack trace? What is different on your remote server? Is the port open? – superkhau Dec 05 '14 at 18:04
  • No I've built it on a dedicated server and doing the command below on my mac returns 1: nc ip port < www.example.com:3001; echo $? – Emmanuel Henri Dec 05 '14 at 18:20
  • Thanks guys the port was the issue....damn...I wish I would've thought of that. So obvious! :) – Emmanuel Henri Dec 05 '14 at 22:27
  • Can you upload the code somewhere? Not sure what is different on your remote server. If it works locally, just do the same on the remote server. – superkhau Dec 06 '14 at 03:42
  • Thanks for your help but I solved the problem. It wasn't the code but the fact that my remote server didn't have the right port opened. I appreciate your help! – Emmanuel Henri Dec 07 '14 at 04:02
  • NP, glad you got it working. ;) – superkhau Dec 11 '14 at 00:09

1 Answers1

0

The port was the issue, see the comments in the question. Closed.

superkhau
  • 2,781
  • 18
  • 9