Search code examples
firebasefirebase-realtime-databasegoogle-cloud-functionsfirebase-hosting

How to save text file in firebase hosting using firebase functions


I want to generate sitemap from firebase db using firebase functions.

The last step would be saving the generated xml file somewhere near to the index.html to give the relative path to the google.

How i can save the xml file in firebase function to the firebase hosting path.

Thanks.


Solution

  • There is no API to manipulate the contents of a Firebase Hosting site. So you can't save a file to a hosting path directly.

    Instead there is an integration between Firebase Hosting and Cloud Functions that allows your Cloud Functions code to be called for specific URLs that you specify. The result of the function is then stored in the Firebase CDN, and cached according to the headers you specify. You could generate your sitemap in such a Cloud Function.

    To learn more about this approach, read the Firebase Hosting documentation on the integration.