App引擎nodejs部署错误

时间:2017-08-20 21:29:34

标签: node.js google-app-engine google-cloud-platform

我正在尝试特定的 Google Cloud Platform App Engine

为此,我创建了一个简单的nodejs应用程序,它只在响应中发送 Hello Wold 消息。

但我无法访问端点并收到以下错误 enter image description here

下面的

是我的文件:

aap.yaml

runtime: nodejs
env: flex

index.js

'use strict';

const http = require('http');
const port = 443;

const requestHandler = (request, response) => {
  console.log(request.url);
  response.end('Hello Node.js Server!');
}


const server = http.createServer(requestHandler);
server.listen(port, (err) => {
  if (err) {
    return console.log('something bad happened', err)
  }
  console.log(`server is listening on ${port}`)
});

的package.json

{
  "name": "test-pro-for-gcm",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "deploy": "gcloud app deploy",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

更新1 在GCP日志中,16:31:59.000 server is listening on 443

1 个答案:

答案 0 :(得分:0)

将接收HTTP请求的端口为8080。

使用代码中的PORT environment variable使其与App Engine环境兼容:const port = process.env.PORT || 443;