Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

node.js - Genrating rss.xml for Angular 8 app locally works fine, but not on prod

I am trying to generate a rss.xml file for my angular 8 app with ssr + firebase + gcp inside the domain.

I've created a RssComponent which can be reached at /rss route. There i call getNews() method and recieve an array of objects. Then I make a http request to /api/rss and in server.ts i handle that request:

app.post('/api/rss', (req, res) => {
  const data = req.body.data;
  const feedOptions = // defining options here
  const feed = new RSS(feedOptions);
  data.forEach((item) => {
    feed.item({
      title:  item.headingUa,
      description: item.data[0].dataUa,
      url: item.rssLink,
      guid: item.id,
      date: item.utcDate,
      enclosure: {url: item.mainImg.url.toString().replace('&', '&'), type: 'image/jpeg'}
    });
  });
  const xml = feed.xml({indent: true});
  fs.chmod('dist/browser/rss.xml', 0o600, () => {
    fs.writeFile('dist/browser/rss.xml', xml, 'utf8', function() {
        res.status(200).end();
    });
  });
});

And finally on response i'm opening the recently generated rss.xml file in RssComponent. Locally everyting is working fine but on google cloud platform it's not generating a file.

question from:https://stackoverflow.com/questions/65920730/genrating-rss-xml-for-angular-8-app-locally-works-fine-but-not-on-prod

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...