为啥hapijs v17版本部署到谷歌云上一直返回502错误?给40分!

以下是一个hello word 代码

const Hapi = require('hapi');

// Create a server with a host and port
const server = Hapi.server({
    port: 3000,
    host: '0.0.0.0'
});

server.route({
    method: 'GET',
    path: '/',
    handler: (request, h) => {
        return h.response("123").code(200);

    }
});


const init = async () => {

     await server.start();
     console.log(`Server running at: ${server.info.uri}`);
};


init();

hapi v17必须用async,直接运行 node app.js就行不需要babel,但是部署到google云的app engine上一直是502 nginx bad gateway。。我有一个大项目也是hapi js部署后看log可以运行,但是就是一请求返回502.。。我猜可能是response不能被nginx转发。。情深看看这个hello word代码。。。。我localhost可以运行就是谷歌云不可以为啥呢?谢谢!

https://www.cnblogs.com/wzgj/p/8867417.html

可能是nginx配置的问题,你不用nginx,直接本地ab或者wget之类的测试下看看是不是有问题,确认是nginx还是项目的问题。

小哥 你可以把
const server = Hapi.server({
port: 3000,
host: '0.0.0.0'
});
把host 去掉试试
const server = Hapi.server({
port: 3000
});
我再部署阿里云的时候就出现过这种问题