Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Functions - generate and host static webpage

I'm using Firebase Cloud Functions to generate an HTML file and now I'd like to host it together with related assets (js, css, fonts etc.) but without success.

I call the function, it generates the file properly and puts it in Firebase Storage together with js/css/other assets. Now I would like to return a URL of the index.html file so that the user can access it in the browser and the .html page will have access to the assets. Unfortunately the generated URL enforces download but I'm pretty sure that even if I managed it somehow, it won't be able to access asset files.

I know it's possible on AWS (S3 bucket) but can I do it on Firebase? Firebase Hosting doesn't seem to be the right solution in that case, does it?

like image 907
Pramus Avatar asked Oct 27 '22 16:10

Pramus


1 Answers

Don't save it to Storage, that's a bad use case for this scenario. Instead, save it to Hosting:

https://firebase.google.com/docs/hosting/

Also, you can consider serving the content directly from the cloud function, probably there's no need to create a static version first.

like image 193
Sergio Flores Avatar answered Nov 16 '22 11:11

Sergio Flores