节点应用程序无法在openshift中运行

时间:2016-07-04 09:05:42

标签: node.js openshift hapijs

我正在运行一个HAPI节点服务器来为我的js代码库提供服务。服务器似乎运行正常。但是,点击url会抛出503错误。

const store = configureStore();
const initialState = store.getState();

//from environment variable grab our data and the backend data
const hostname = process.env.OPENSHIFT_NODEJS_IP;
const port = process.env.OPENSHIFT_NODEJS_PORT;
const restHostUrl = process.env.SERVER_URL || "localhost";
const restHostProtocol = process.env.SERVER_PROTOCOL || "http";
const restHostPort = process.env.SERVER_PROTOCOL || "1337";

//creating hapi server - popping my cherry with hapi on this one - im more of an express kinda guy.
const server = new Server();
server.connection({host: hostname, port: port});
server.register(
  [
    h2o2,
    inert,
    // WebpackPlugin
  ],
  (err) => {
  if (err) {
    throw err;
  }

  server.start(() => {
    console.info("==> ✅  Server is listening");
    console.info("==>   Go to " + server.info.uri.toLowerCase());
  });
});
...

1 个答案:

答案 0 :(得分:0)

愚蠢的问题。 Webpack正在将process.env.openshift转换为其他int dist / server.js,导致它使用localhost,从而导致问题。