Экспресс в FireBase Облачные функции Ответ XML RSS поток - PullRequest
0 голосов
/ 13 марта 2019

Я пытаюсь предоставить RSS-каналы своим посетителям в корне / feeds

Я использую шаблон react-redux-firebase от Net 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"

Почему это?

ссылка: (если вы видите результат XML по этому URL, это означает, что я уже решил проблему)

...