如何解决Angular / hapi.js提供静态文件
我想运行index.html文件,该文件是通过使用Node.js服务中的Angular构建制作的
这是我的index.js文件内容(hapi.js)
server.route({
method:'GET',path:'/home',handler:(req,res) =>{
return res.file('public/index.html')
}
});
文件的关联如下,
Project Folder
├───index.js
├───package.json
├───package-lock.json
├───public
├───index.html
├───assets
运行此代码时,发生以下错误,
{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"}
Server running on http://localhost:3000
Debug: internal,implementation,error
TypeError: res.file is not a function
at handler (D:\API\index.js:40:16)
at exports.Manager.execute (D:\API\node_modules\@hapi\hapi\lib\toolkit.js:60:33)
at Object.internals.handler (D:\API\node_modules\@hapi\hapi\lib\handler.js:46:48)
at exports.execute (D:\API\node_modules\@hapi\hapi\lib\handler.js:31:36)
at Request._lifecycle (D:\API\node_modules\@hapi\hapi\lib\request.js:365:68)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Request._execute (D:\API\node_modules\@hapi\hapi\lib\request.js:274:9)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。