I'm following this tutorial Getting Started with Firebase Hosting on the Web - Firecasts
I'm trying to host a simple index.html file in firebase but when I type firebase deploy its gives me the following error:
No targets found. Valid targets are: database,storage,functions,hosting. hosting error image
I found my firebase.json file is empty it contains only { } .
run firebase init again.
When you are asked for - Which Firebase CLI features do you want to setup for this folder?
Press Space to select features, it will mark that feature with asterisk.
Then Enter to confirm your choices.
Make sure you select the options by pressing spacebar, then press enter.
run firebase init and if your firebase.json is empty with only {} then add
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
replace "public": "app" with "public": "public"
then run firebase deploy
Related
`
{
"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.
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.
I was hosting a Flutter Web project using Firebase Hosting.
I did firebase init then firebase deploy but my hosted website looks like this:
I think you also this kind of error while hosting.
Answering my own question as I didn't find an answer that helped me out. So I found a way out.
After doing firebase init and selecting a few options as per you choice, firebase creates a firebase.json file which looks like this:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
If you do firebase deploy here, you'll be seeing the same website as shown in the question.
Here's what you can do to avoid it.
STEP1: flutter clean
STEP2: flutter build web
STEP3: firebase init
STEP4: Now before doing firebase deploy, make sure you change the "public" directory to "build/web" as shown below, as that is the web flutter has built.
{
"hosting": {
"public": "build/web",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
I hope this answer helped you out. Peaceā
I'm trying to verify the domain for Apple Developer, who require the verifiable location to be:
https://[website name].com/.well-known/apple-developer-merchantid-domain-association.txt
The trouble is coming in at the '/.well-known/' segment, I've written the directory as '\.well-known' which works but when I deploy hosting to update the files on my website I can't find it.
I've taken out the "**/.*" from ignore, so it doesn't ignore files with a full stop in. Here's what's left in case I've missed anything:
"hosting": {
"site": "[website name]",
"public": "public",
"cleanUrls": true,
"ignore": [
"firebase.json",
"**/node_modules/**"
]
}
}
Is there something I'm missing?
I solved it by using mkdir to create a hidden folder called '.well-known' in the terminal and showing hidden folders.
I added target to firebase project because there is going to be subdomains. I've done this before, but never encountered this error. So I created the project in the firebase console. Then I opened the project in my terminal.
firebase init
... chose existing project // Website
firebase deploy // website is now live at firebase domain
Then I added a target...
firebase target:apply hosting website Website
Now I went to my firebase.json file and it looks like this
{
"hosting": {
"target": "website" // this causes Error: 404, Requested entity was not found
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
I'm getting the error after I add that target and run firebase deploy in the terminal. Maybe I need to add the target to my firebase.rc as well?