How do we host AMP pages over Firebase hosting? | #AskFirebase - firebase

Is it possible to create website using AMP pages that can be hosted over Firebase hosting..?
If yes, is that possible to create dynamic AMP pages that can add & fetch data to/from Firebase Firestore..?
If yes, please explain how is that possible..?
AskFirebase
Thanks!

Yes, it is possible. You can generate AMP compatible templates that are served over firebase hosting, or via an https triggered firebase function.
Firebase functions hosting documentation: https://firebase.google.com/docs/hosting/functions
Your firebase function can dynamically fetch and serve data from Firestore / Realtime database. You can also implement caching so that static html is served from a CDN.
Creating an AMP page from scratch:
https://www.ampproject.org/docs/tutorials/create/basic_markup
Just follow the AMP guide to ensure your code structure and syntax is correct.
Obviously this answer is very simple compared to implementation, but hopefully that gives you some direction and an idea of what is possible.
Server Side Rendering Tutorial
Google has a video series on server-side rendering with Firebase, I highly recommend it: https://www.youtube.com/watch?v=nbTn1czE2L8&list=PLl-K7zZEsYLkbvTj8AUUCfBO7DoEHJ-ME

Related

Do firebase dynamic links work with PWA applications?

Firebase dynamic link documentation does not show Web as a category it supports but I wanted to know if there is any hack out there where can get it to work for PWA applications? the google analytics tracking for firebase is a powerful feature, especially for dynamic links.
Even though there is no specific API for this, since Dynamic Links are just URLs, you can indeed use then within a web app.
For example, we used them in the PWA for the Firebase Summit in 2018 to track click-throughs to the additional information for each session.
If you are having issues with your PWA not running correctly in Facebooks (insert expletive) Mobile Browser. Using dynamic links will force it out to the regular browser)
Do not use a custom domain, use the https://YOURDOMAIN.page.link
and DO NOT skip the preview page!

Google Cloud Storage - Restrict access to files to a specific domain

I am using Google Cloud Storage for my WordPress website and I would like to know if there is a way to restrict access to my files so that only my domain will be able to access them. I tried Google Search but I couldn't find anything. Could you please tell me if I can do that and how?
From your question it is not clear for which purpose you wish to use Cloud Storage for your website.
You can look at this article with respect to Cloud Storage access control. I would recommend looking at IAM since I believe your want to allow domain access to all the files in Cloud Storage.
In general, if you want to host your WordPress website on Google Cloud, several options are available:
WordPress Single Instance using Cloud Launcher
WordPress on Kubernetes Engine
WordPress on App Engine
If you want to integrate WordPress with Google Cloud products, like Cloud Storage, there are plugins available from the Google Cloud Platform GitHub repository.

Firebase hosting allow access to only minified js/css [duplicate]

I am trying to secure some pages behind firebase auth -however every time I try open them - I seem to be able to browse to them. Even when I follow the documentation.
I can't seem to find anyway to restrict the page to be accessible only to authorized users.
Any idea how best to approach this?
Edit: Looks like its not supported directly without building a lot of custom code. It would be brilliant if they can support a simple htaccess file or similar. - Here is a link to post feature request
https://firebase.google.com/support/contact/bugs-features/
All static content (HTML, CSS, JS, and other files) published to Firebase Hosting is publicly accessible if you know the URL. There are no authentication controls you can easily configure to change this behavior.
If you need to protect content, you could set up some code via Cloud Functions that checks the user's authentication and serves the content based on its decision.
I suggest saving needed secret part of HTML/JS in Firestore with security rules and dynamically upload it to page after auth.

Firebase Hosting: Preventing unauthorized access to URL

I am trying to secure some pages behind firebase auth -however every time I try open them - I seem to be able to browse to them. Even when I follow the documentation.
I can't seem to find anyway to restrict the page to be accessible only to authorized users.
Any idea how best to approach this?
Edit: Looks like its not supported directly without building a lot of custom code. It would be brilliant if they can support a simple htaccess file or similar. - Here is a link to post feature request
https://firebase.google.com/support/contact/bugs-features/
All static content (HTML, CSS, JS, and other files) published to Firebase Hosting is publicly accessible if you know the URL. There are no authentication controls you can easily configure to change this behavior.
If you need to protect content, you could set up some code via Cloud Functions that checks the user's authentication and serves the content based on its decision.
I suggest saving needed secret part of HTML/JS in Firestore with security rules and dynamically upload it to page after auth.

Wordpress on new Firebase hosting

I've found out about new Google Firebase Hosting recently and I was wondering if that would work for Wordpress website?
I got a bit confused them talking about static websites & web apps even though as far as I know Wordpress is dynamic...right? on their website it says:
https://firebase.google.com/docs/hosting/#key_functions
Whether you are deploying a simple app landing page or a complex Progressive Web App, Hosting gives you the infrastructure, features, and tooling tailored to deploying and managing static websites.
It looks like a nice Hosting platform for web, especially that they provide SSL certificates, but is it good for Wordpress?
Thanks!
I THINK it would be possible, you still need your SQL+PHP server and you should use it as WordPress backend, you need the WordPress REST API and a plugin with hooks in transition_post_status, comments... and whatever you want to show in your front end, use WordPress API endpoints to send the JSON to the firebase database... after your template should use a Javascript framework in order to make JSON requests to the firebase database and show the data in the browser... It would be difficult but I think it could be the cheaper and best solution ever for a high traffic website (plus all the benefits of firebase).
Nope. Firebase doesn't provide any of the requirements necessary for Wordpress, that being MySQL and PHP on the server side. Firebase provides a JSON store accessible via an API, and static hosting for apps that can access said API.

Resources