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?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/28ee4959-7001-4737-8df2-e17eb9f0b779%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.