Node.js 如何从firebase函数访问firebase宿主文件
我有一个简单的firebase函数,它必须发送一个文件来响应文件位于/app/one.html中的请求 我的项目目录结构Node.js 如何从firebase函数访问firebase宿主文件,node.js,firebase,firebase-hosting,Node.js,Firebase,Firebase Hosting,我有一个简单的firebase函数,它必须发送一个文件来响应文件位于/app/one.html中的请求 我的项目目录结构 blog |____app |____index.html |____one.html |____functions |____index.js 我必须访问one.html并从senFile()发送它 index.js const functions = require('firebase-functions'); exports.blo
blog
|____app
|____index.html
|____one.html
|____functions
|____index.js
我必须访问one.html并从senFile()发送它
index.js
const functions = require('firebase-functions');
exports.blog = functions.https.onRequest((req, res) => {
res.status(200).sendFile('app/one.html'); #here I need something to do
});
据我所知,
firebase deploy
for functions只部署functions文件夹的内容。所以,如果您将应用程序文件夹移动/复制到functions文件夹的内部,您就可以实现您的目标
blog
|____functions
|____app
|____index.html
|____one.html
|____index.js
正确更改路径后,您可以像express应用程序一样发送文件
res.sendFile(path.join(__dirname + 'app/one.html'));
如果你想发送
one.html
用它替换index.html
。好的,不管它是什么文件,都应该访问它@克甘加达尔