Hi guys, I'm currently deploying a simple hapi.js v17.x on App engine which is a hello word project. After i deployed it, i tried to get access to "/" which should have returned a hello work but it returned 502 status code instead (502 bad gateway). When I use hapi.js v16 it was deployed successfully tho.
The difference is that in v17 they use async function and in v16 they use callback. I will show you the code:
hapi v17 NOT WORKING (502 BAD gateway)
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 'Hello, world!';
}
});
const init = async () => {
await server.start();
console.log(`Server running at: ${server.info.uri}`);
};
init();V16 working fine: D
const Hapi = require('hapi');
// Create a server with a host and port
const server = new Hapi.Server();
server.connection({
host: '0.0.0.0',
port: process.env.PORT || 8080
});
server.route({
method: 'GET',
path:'/',
handler: (request, reply) => {
reply('Hello World!');
}
});
server.start(() => {
console.log('Server running at:', server.info.uri);
});I would like to know why in v17 they always return 502?