[英]getting a 502 gateway error when deploying hapijs to google app engine
The logs tell me the favicon is not being served 日志告诉我,该网站图标未投放
"GET /favicon.ico" 502
app.yaml 的app.yaml
runtime: nodejs
env: flex
server.js server.js
const Hapi = require('hapi');
const Vision = require('vision');
const Inert = require('inert');
const Path = require('path');
const Handlebars = require('handlebars');
async function start() {
const server = new Hapi.Server({ host: 'localhost', port: process.env.PORT || 8080 });
await server.register([Inert, Vision]);
server.views({ engines: { html: Handlebars }, path: `${__dirname}/templates` });
const rootHandler = (request, h) => {
return h.view('index', {
title: "Data Controller",
message: "All hail the DC Dashboard",
meta: `Hapi ${request.server.version}`
});
};
server.route({ method: 'GET', path: '/', handler: rootHandler });
server.route({ method: 'GET', path: '/{param*}', handler: { directory: { path: `${__dirname}/public` }}});
server.route({ method: 'GET', path: '/favicon.ico', handler: { file: `${__dirname}/public/favicon.ico` }, config: { cache: { expiresIn: 86400000 }}});
try {
await server.start();
}
catch (err) {
console.log(err);
process.exit(1);
}
console.log('Server running at:', server.info.uri);
};
start();
folder structure: 文件夹结构:
/
- public
- css
- js
favicon.ico
server.js
I'm just not sure how to resolve this! 我只是不确定如何解决这个问题! Any help appreciated.
任何帮助表示赞赏。
好的,我通过将主机设置为
0.0.0.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.