0

我正在尝试在 /feeds 根目录下向我的访问者提供 RSS 源

我正在使用react-redux-firebaseNet Ninja 的模板

现在我在我的云函数文件中导入节点 Express,如下所示:

const functions = require('firebase-functions');
const admin = require('firebase-admin'); //init admin SDK to use auth, firestore ...
const express = require('express');
const firebaseApp = admin.initializeApp(functions.config().firebase);
const app = express();

getFeeds = () => {
  const ref = firebaseApp.database().ref('projects');
  return ref.once('value').then(snap => snap.val());
};

app.get('/feeds', (request, response) => {
  response.set('Cashe-Control', 'public, max-age=300, s-maxage=600')
  getFeeds().then(feeds => {
    // response.send(feeds);
     response.send(`${Date.now()}, this is feeds: ${feeds}`);
  });
});
exports.app = functions.https.onRequest(app);

但只有当我使用( firebase serve --only functions, hosting)然后当我去http://localhost:5000/feeds时:我明白了

1552472467200, this is the feeds: null

这正在打印到我的控制台:

[hosting] Rewriting /feeds to local function app
info: User function triggered, starting execution
info: Execution took 126 ms, user function completed successfully
127.0.0.1 - - [13/Mar/2019:10:21:07 +0000] "GET /feeds HTTP/1.1" 200 34 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"

这是为什么?

链接:(如果您在此 URL 上看到 XML 结果,则表示我已经解决了问题)

4

0 回答 0