Firebase Deploy Link shows Blank or Deploy complete - firebase

`
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
`Have an issue where the Firebase deploy link shows "Firebase Hosting Setup Complete." I've tried just about everything on stackoverflow with no success.
I have it set to "build" not "public" in my firebase.json for hosting and it's not doing anything.
I've tried messing with the index.html but then the screen just comes up white/blank.
I've also deleted firebase files completely and started the init over. Still comes back the same.
Has anyone else ran into this lately?

It's hard to tell without any code snippets or firebase config files but I believe if you specify your public location as "build" you do not need to include the rewrites property in the firebase.json file. According to The Docs,
Set up rewrites for any of these purposes:
Show the same content for multiple URLs. Learn how.
Serve a function or access a Cloud Run container from a Hosting URL. Learn how: function or container.
Create a custom domain Dynamic Link. Learn how.

Related

Solid JS and Firebase hosting not showing routes

I'm trying out Solid. I hosted a simple web app on firebase that shows the index.html file, but only shows a 404 error for other routes. Solid JS stores its index.html folder in dist/public, along with other files.
404.html favicon.ico manifest.json ssr-manifest.json
assets/ index.html route-manifest.json
The routing works fine in my development server, but not on firebase or netlify. It looks like both firebase and netlify have config options that let you specify redirects, but what html file do I redirect to?
If you ran firebase init your project should have a firebase.json. Here's an example from one of my projects. Notice the rewrites array. It says every link to my website should be handled by index.html, which is where React project is served from. Solid-js should work similarly
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Documentation here https://firebase.google.com/docs/hosting/full-config#rewrites

Firebase emulator: add build steps to hosting

I'm trying to programmatically build my index.html file from a template, using a custom script/pre-deploy hook.
Is it possible to have the Firebase emulator run my predeploy script either (1) on start, or (2) on page refresh, so that I can see in the emulator what will happen on actual deploy?
My script works in actual deployment, but never fires with the emulator.
firebase.json (relevant part)
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"predeploy": "node ./preDeploy.js",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
preDeploy.js (oversimplified minimal example)
const fs = require('fs');
const testString = 'hello';
fs.writeFileSync('./preDeployTest.txt', testString);
I would expect the test file to be generated (1), ideally every time I refresh my site while running the emulator, or (2) at least when I first start the emulator -- but the script only runs on actual deploy.
To be clear, I'd be using this script to generate the file that I want Firebase hosting to use as its index.html, but I want to be able to emulate the results.
This may be possible with the default lifecycle scripts block:
"scripts": {
"prepare": "node ./prepare.js"
}
There's also preprepare and a few other hooks; you may have to toy with it to find the correct one. The point is, that one isn't limited to Firebase specific hooks, but can use those defined by NodeJS.

Firebase doesn't default to index.html

Trying to deploy my React app on Firebase. The problem is that after I deploy the app and connect to the default "app.web" domain I keep getting "Site Not Found" page. I followed the initial steps and bundled the app with parcelJS.
However adding /index.html at the end resolves my issue.
Connecting to the "firebase.com" domain works as expected without the need of adding "index.html" at the end.
My previous project which I now removed worked seamlessly without such issues.
What causes this behavior? Can I do anything to fix it?
Contents of firebase.json
{
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
The rewrites are correct for a single page app. it maybe an issue related to your browser cache, try another browser or clear your one with Ctrl F5.
If issues persist, you should look at your react app and double-check any router paths and that you do have an existing public folder in the root with your index.html and your react app setup correctly.
As a last resort incase something severe maybe broken, you can create a new project folder and init your Firebase project into it and copy your react src folder over and rebuild your public folder, firebase.json, etc and redeploy with firebase deploy --only hosting

Wrong page loading by default on firebase link. How do I change the default page that loads? | Firebase hosting

Question
I just set up firebase. However, when I load the link that firebase provided it gives me an 'Error 404'. Now I know that the website is hosted correctly, because when I ran the local host, I then entered the following extension on the end of the url: '/html/index.html' - and it worked.
However, firebase is not finding the correct page to load.
How can I change the page that loads by default, when someone visits my website?
For context
I am pretty sure I know what firebase is doing here. When I first ran the local host, it was running the default index.html that firebase provided. Now that I have deleted that default index.html. It doesn't know where to look to find the page to run.
My index.html is within a folder that is within the public folder. The name of that internal folder is html.
This is the current set up of the file structure and my attempt to fix the problem so far (based on advice of Renaud):
Update
I have now implemented the following, but it is loading #404
As explained in the doc for Hosting configuration, in order to redirect the traffic to your index.html page (or to another html file), you need to add the following to the firebase.json file which is at the root of your project directory:
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
OR
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"destination": "/mySpecificHomePage.html"
}
]
},
As explained here, "the public attribute specifies which directory to deploy to Firebase Hosting. The default value is a directory named public, but you can specify any directory's path, as long as it exists in your project directory."
Update following your update (screenshot of your Firebase project file structure):
If I am not mistaking you should do as follows:
"hosting": {
"public": "html",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
Note that rewrites is within hosting!

Unable to deploy firebase project to custom domain

Took a free domain on freenom
Linked it successfully with a project on firebase
Added a target name to the domain
Added the target to
firebase.json
on running firebase deploy
Error : HTTP Error 404
Could someone point out what i'm doing wrong cause I followed all the steps on the firebase website but still am unable to get it running. The HTML file I want to host just has a H1 tag with "Hello World".
You do not require any special steps to deploy the site on custom website. Once your site is up on the default domain. Then the website gets automatically replicated on you connected custom domain. Hope this helps you.
This is my firebase.json file:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}

Resources