Ad

Some Confusion About Firebase Regarding Static Vs Dynamic Pages

So according to docs I've read, a webpage written in html code which includes script src="some_JavaScript_file.js is always a dynamic page even though the embedded JavaScript only has const sum=3+5 because no matter how simple it is, as long as there's even a tiny amount of backend involved, that webpage is definitely a dynamic webpage. so with that premise(please confirm that the premise I wrote is actually correct), my question is how does it make sense that Firebase claims it runs index.html sitting in Public folder ONLY when it's running a static webpage even though if that index.html file includes script src="some_JavaScript_file.js, it's a dynamic webpage?

Ad

Answer

Firebase Hosting doesn't interpret the content you host on it in any way. So if there's JavaScript in any of your files, Firebase doesn't execute that JavaScript code on its servers. Same for any other code: Firebase will serve the code as text (or whatever other format you stored it in) to clients that request it.

If your pages contain JavaScript that you want to run in the client's browser, that is precisely what you want. So you can serve a web site that contains client-side JavaScript on Firebase Hosting.

If you have any code that you want to run server-side you will have to look beyond Firebase Hosting. Nowadays you can stay within Google's infrastructure by integrating Firebase Hosting with Cloud Functions or Cloud Run.

Ad
source: stackoverflow.com
Ad