We have picked up a very messy half built project and are trying to get it into an external beta testing state...
It is a next.js application which works fine if we run npm run build and then npm run start.
We prefer to host it on Firebase, for all the normal reasons and I believe it should be possible to do so.
However, when we install firebase and enable firebase experiments:enable webframeworks and firebase init hosting and accept the default options (Y,N) it adds the standard firebase index.html to the public folder - even though it didn't ask if we wanted that...
If we leave that index.html in place in the public folder then run firebase serve or firebase deploy, the /public/index.html is delivered as the root page of our site. When it should be the Index of the next application. If we delete the firebase index.html, and then rerun firebase serve to rebuild, then we get an 'undefined url' error (as it can't find the /public/index.html presumably).
We have an index.tsx in the /pages dir and when we run firebase serve, the build process does seem to be placing index-xxxxx.js chunk files etc. in .firebase/sitename/hosting/_next/static/chunks/pages.
We have tried adding rewrites in the firebase.json of various sorts, changed versions, everything we can think of. But still can't work out why firebase is not recognising the site root index page when it is running just fine on npm run start.
Any help appreciated to help us troubleshoot.
I am new to Firebase but I am the owner of a project.
I have also given permission to someone to be an "editor" of the project.
Initally there was only 1 site and URL for my project. In the hosting, I now notice that are 2 sites for the same project. One with the url mydomain.web.app and the other with mydomain-f9745.web.app.
When I deploy code it goes to the first domain and when the editor deploys it goes to the second domain. Can anyone explain what is happening here. It seems that when the editor deployed the code for the first time, it created a new domain instead of using the existing one.
I have also tried to see how I delete the second site but I don't see that option.
Can anyone explain why this second site it being created please?
once you set up firebase hosting you're automatically allocated with a domain .web.app.
Seems, like mydomain-f9745 might be the one that is the default one.
Anyway, you can add more web.app domains to your project like mydomain.web.app.
I'm not sure about the difference you're saying between just "deploying" and "deploying from your code editor".
Note that you can specify the default site to be deployed to on your firebase.json file like this:
{
"hosting": {
"site": "my-site"
/// other hosting config
}
}
Just add a "site" property inside "hosting", and enter the site name (Do EXCLUDE .web.app).
Hope this helps!
I've setup a custom domain to use for firebase Dynamic Links. Hosting has been setup in Firebase Console and I tried to use dynamic links without the customdomain, but just a xxx.page.link.
Now I want to return to use the custom domain, but from the console I'm told that:
A configuration already exists for this site. Add the snippet below to your firebase.json file and redeploy your changes. Be sure the rewrite rule is the first match for your dynamic link.
I'm not exactly sure how to handle this. Should I use the CLI and init a project to make this change or can I somehow do this from the portal itself.
If I need to use the CLI, how do I then access the existing project and make the change?
It seems you're already using Firebase Hosting outside of just for Dynamic Links. In that case you'll need to configure it through the CLI.
The configuration for Firebase Hosting must be made through deploying the firebase.json file through the Firebase CLI. There's no way to configure this directly in the Firebase console.
You can create an empty directory, run firebase init in there, and configure it to your existing project. Once that is done, you can create and deploy the minimal firebase.json file required as shown in the documentation on setting up your custom domain.
So I have built a simple firebase and javascript app that uses firebase database and hosting.
I have successfully built the app and deployed to Firebase hosting, however when the cmd provides the url that leads to the app it takes me to some completely random firebase landing page.
All deployment is correct and I know all my code is correct, but it keeps sending me to the random landing page: https://firebase.google.com/docs/hosting/
When you first create a project on firebase it asks you for the public directory: What do you want to use as your public directory? public
Usually the default its public, so the firebase generates a random welcome index.html there.
When you setup the firebase init configure the public directory to your files and you should see your app instead of the welcome index file, or simply put all your files inside the public directory you've chosen above.
Here I found a very simple tutorial on how to get started on that: https://www.brooks-patton.com/deploying-a-static-website-to-firebase/
Another way - you can just edit firebase.json file, in the line with "public" change the path where is your code was built.
I have a hosted site on firebase which I am not using anymore. I still want to keep the project but want to remove the hosted site. Is there any way to do this or do I just need to upload an empty directory. Doesn't seem to be an option in the UI
It can be deleted.
Run firebase hosting:disable through the firebase-tools CLI first.
Go to Firebase Console and select Hosting from the menu of the left.
You will see the deployed project with a list of your historical actions like Deployed, disabled, etc.
Only after you have disabled the site, the "three vertical dots" menu will be available for you to choose the action to delete the deployment.
If you have multiple site hosted in same project, then use -s flag to specify the site you want to disable.
firebase hosting:disable -s yoursitename
You don't need to upload empty directory.
Just open your project's root directory and enter the following command
firebase hosting:disable
CLI Response :
$ firebase hosting:disable
? Are you sure you want to disable Firebase Hosting for the site xyz
This will immediately make your site inaccessible! Yes
✔ Hosting has been disabled for xyz. Deploy a new version
to re-enable.
This will instantly disable running website also adds a Disabled status in release history. Tested on firebase CLI version 9.20.0
It's a bit hidden, but here are the steps:
Go to the Firebase Hosting console for your project, you will see your domain.
Hover over your domain. There's an overflow menu (⋮ three vertical dots) on the right.
From the overflow menu select Delete Domain
[Update]
For multiple site hosted !! use command
firebase hosting:disable --project yoursitename
for me it work!! Can your try?
You can use the following command:
firebase hosting:disable -s <firebase_project_name>
replace <firebase_project_name> with the name of your firebase project. This allows you to unsubscribe from the current project and place it in disable mode and you cannot receive traffic from the published web page. When you want to re-enable it, you can do it from the visual platform. I leave an image attached so that you can be guided.
Manually
You can easily go to the console, and click on the 3 vertical dots and delete the site.
Using CLI
Disable only
Stops serving Firebase Hosting traffic for the active Firebase
project.
Your project's Hosting URL will display a "Site Not Found" message
after running this command.
If you want to disable, as the other answers are saying use this command:
firebase hosting:disable
If you're using multi-sites, you have to specify the project name:
firebase hosting:disable --project yoursitename
Delete forever
Deletes the specified Hosting site.
Deleting a site is a permanent action. If you delete a site, Firebase doesn't maintain records of deployed files or deployment history, and the site cannot be reactivated by you or anyone else.
(Optional) Skip the confirmation prompt by passing the following flags: -f or --force
To delete this site (similar to when you go to the console > delete manually) run this command:
firebase hosting:sites:delete yoursitename -f
Be careful when using the -f, but if you're running this as a script command, it might be required.
I spent too much time on this and hopefully this can be helpful. I did deploy my stuff using firebase deploy however I was not able to see in on the firebase console. When I tried firebase hosting:disable I got this Error: HTTP Error: 400, Invalid project ID specified.
The steps below helped me delete my project.
To find the project, you have to get the output of firebase
deploy which will have a console url that looks like this:
Project Console:
https://console.firebase.google.com/project/<your-project-id>/overview.
Follow this link and go to project settings. You should be able to
delete your project in there.
I had to spend several hours removing the default website on Firebase hosting.
The way that I found was :
Enter "firebase init database" in Terminal. It initialize all websites including the default one so that you can set up a new one.
I hope it helps you.
As of now there is no proper way to bulk delete all the previous deployments in a project.
However the best thing you can do is to empty the firebase hosting folder and then deploy it using firebase deploy
This option has been given as a feature request to firebase. Lets hope its get implemented soon :)
1.Sign in to Firebase, then open your project.
2.Click the Settings icon near project Overview button, then select Project settings.
3.In the Your apps card, select the app that you want to delete.
4.Find the Delete Project button from bottom of the page , click Delete Project.
5.Check the points , then click Remove app permanently.