So I just wanted to host my Firebase Functions on my custom domain without hosting anything. I host my website somewhere else already.
Unfortunately, Firebase throws errors when trying to deploy functions with rewrites BUT without the public directory OR when the public directory is empty.
How can I do that on Firebase without a hack and hosting some redundant stuff? I just want to host the functions on a custom domain.
It seems that Firebase Hosting requires at least one html page, even if your only hosting functions. Just add a blank index.html to a directory and point hosting to that.
Related
I am having an issue with using Next.js API routes when deploying my website to Firebase Hosting. Here is the api call:
And here is the set up in the pages directory:
Here is the function used in email.js:
I changed the variables as to not give away my email address.
The call works when I use local host. However, when I build and deploy to firebase. I have tried to use the firebase url to make the api call, but I get a 404 page not found. I am not sure how to fix this. I would really appreciate any help.
Firebase hosting only hosts static files which is why your api routes don't work there. If you had a fully static Next site, you could host it on Firebase hosting. But if you want to use the api routes in Next, you need a server. One way to do this (albeit complicated) is to set up Firebase Functions with your api code and then rewrite requests in Firebase Hosting to that Firebase Function. It's complicated because it would require a fairly complex deploy process.
If the rest of your site is static, you can use Firebase Hosting for that and then consider ditching the api routes and instead setting up a Firebase Function to act as your api completely separate from Next.
Or if you want to keep it all in Next, consider something like Vercel for your site + api via Next.
I have followed the firebase guidelines to host the website on firebase hosting, but the content of the website is not visible . I am seeing this on my screen as shared in the picture
what should i do about? please guide
Ensure that you have setup your website in the correct folder as Firebase uses folders to contain data for specific services, public for hosting and functions for cloud functions. You can find out what folder this is by opening the firebase.jsonfile at the root of your project You should find something similar if you usedfirebase init` correctly
"hosting": {
"public": "public",
Once you run the command firebase deploy or firebase deploy --only hosting everything inside this folder is uploaded to your hosting website.
Make sure you also check both URLs provided by Firebase as the web.app URL tends to take longer to update and deploy.
<project-id>.firebaseapp.com
Beyond these fundamental tips I would also make sure that your entry point into the website is also correct, opening the hosting folder (public or otherwise) - and opening up the index.html within should yield you the same site found on *.firebaseapp.com
I'm currently creating a website that is hosted on a vServer from another provider where you can upload images. I'm uploading the images to Firebase Storage. Can I change the domain when I rightclick -> view graphic that is my own domain? I already know that you can change the domain of firebase when you host the website there, but I don't want to host the website there.
There is no way for you to control the URL that is used to serve files directly from Firebase Storage. The download URLs are controlled by Firebase and always are based on your bucket/project name.
But Firebase server-side logic is a fairly thin wrapper around Google Cloud Storage, and you can set up a custom domain for Cloud Storage. You can ignore the parts that talk about this as being specific to hosting a web site there, as a web site on Google Cloud Storage is not much more than the files it consists of, you can apply the same to hosting other files. That should allow you to control the domain from which your files are served.
The final alternative would be to host the files on Firebase Hosting, which means they'll be served from a CDN with many global end points. The main difference here is that Firebase Hosting is typically better suited for files you generate, and not so much for files that your users generate.
I have my own domain i.e www.example.com, and I just connected with Firebase Hosting, however what I want is to deploy a website (using Flutter) for that domain and a different one with the following path: www.example.com/other, as you can see the /other should direct to another website that I have, is that possible throw Firebase Hosting? or do I need to have two domains one for each website
Firebase Hosting only deploys a single site in its entirety, using all of the content in a single folder, usually called "public" in your project. It doesn't really do partial updates scoped to a specific path.
You can certainly deploy multiple apps to one site. You will just have to make sure all of their content is added to that public folder for deployment as a unit. If you don't want to do that, you can certainly manage each site independently with a different hostname for each.
I have a Vue.js app and use Firebase Hosting to serve the static files to users.
Does Firebase Hosting have a method for putting the app into maintenance mode remotely? Without having to do firebase deploy
Maybe something that will allow me to redirect all the traffic to some other index.html, and be able to manage it from Firebase.
P.S. I've already looked into Firebase Remote Config (and it doesn't fit my use case, and their web related tools aren't fully implemented yet). And I'd like to avoid having a realtime database just for maintenance mode.
There is no mode-switch built into Firebase Hosting for temporarily serving other content.
But given the recent updates to deploy efficiency, it should be pretty low-cost to put up a temporary index.html while making the changes. Alternatively, you could deploy rules (in firebase.json) that temporarily redirect all traffic to a wip.html (for work-in-progress).
Which of these works best, depends on your current content structure. I.e. if you already redirect "all" traffic to index.html, I'd probably go with a rewriting solution.
You can also unroll your last deploy in one command.
Deploy maintenance page
Unroll when its done
Don't forget to send a 503 error for googlebot, asking it to come back in X hours.