I'm trying to host a website in Firebase Hosting (free plan), I followed the steps but it does not generate the file firebase.json
my steps
1- firebase login
Already logged in as r*****#gmail.com
2- firebase init
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
C:\Users\Rafael de Azeredo
Before we get started, keep in mind:
You are initializing in an existing Firebase project directory
? Are you ready to proceed? Yes
? Which Firebase CLI features do you want to setup for this folder? Press Space to select features, then Enter to confi
rm your choices. Hosting: Configure and deploy Firebase Hosting sites
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
i .firebaserc already has a default project, skipping
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.
? What do you want to use as your public directory? public
? Configure as a single-page app (rewrite all urls to /index.html)? No
? File public/404.html already exists. Overwrite? No
i Skipping write of public/404.html
? File public/index.html already exists. Overwrite? No
i Skipping write of public/index.html
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
Firebase initialization complete!
3- firebase deploy
=== Deploying to 'myhosting-dfe25'...
i deploying database, hosting
i database: checking rules syntax...
+ database: rules syntax for database myhosting-dfe25 is valid
i hosting: preparing public directory for upload...
+ hosting: 2 files uploaded successfully
i database: releasing rules...
+ database: rules for database myhosting-dfe25 released successfully
Deploy complete!
Project Console: https://console.firebase.google.com/project/myhosting-dfe25/overview
Hosting URL: https://myhosting-dfe25.firebaseapp.com
4- https://myhosting-dfe25.firebaseapp.com
but when I open the page I get this message instead of my index.html:
Welcome
Firebase Hosting Setup Complete
You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!
Can someone help me please?
Create file firebase.json in root directory in y project:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
after run command:
firebase use --add
choose y project and deploy:
firebase deploy
That link displays the default index.html file that Firebase puts in the /public folder on your computer. When you deployed the site it has uploaded that default index.html home page.
If you have your own index.html page to upload, either it wasn't in your /public folder or perhaps the install of Firebase overwrote it.
You need to replace that index.html file with the home page you code.
Related
I am following the steps to host my flutter helloworld application. All steps go smooth, however instead of my application I see this screen.
What can be wrong?
My commands:
polinach-macbookpro3:my_app1 polinach$ flutter build web
💪 Building with sound null safety 💪
Compiling lib/main.dart for the Web... 391ms
polinach-macbookpro3:my_app1 polinach$ firebase init hosting
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/Users/polinach/_/__/my_app1
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? Please select an option: Create a new project
i If you want to create a project in a Google Cloud organization or folder, please use "firebase projects:create" instead, and return to this command when you've created the project.
? Please specify a unique project id (warning: cannot be modified afterward) [6-30 characters]:
polina-test2
? What would you like to call your project? (defaults to your project ID)
✔ Creating Google Cloud Platform project
✔ Adding Firebase resources to Google Cloud Platform project
🎉🎉🎉 Your Firebase project is ready! 🎉🎉🎉
Project information:
- Project ID: polina-test2
- Project Name: polina-test2
Firebase console is available at
https://console.firebase.google.com/project/polina-test2/overview
i Using project polina-test2 (polina-test2)
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.
? What do you want to use as your public directory? build/web
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? Set up automatic builds and deploys with GitHub? No
? File build/web/index.html already exists. Overwrite? Yes
✔ Wrote build/web/index.html
i Writing configuration info to firebase.json...
i Writing project information to .firebaserc...
✔ Firebase initialization complete!
polinach-macbookpro3:my_app1 polinach$ firebase deploy --only hosting
=== Deploying to 'polina-test2'...
i deploying hosting
i hosting[polina-test2]: beginning deploy...
i hosting[polina-test2]: found 21 files in build/web
✔ hosting[polina-test2]: file upload complete
i hosting[polina-test2]: finalizing version...
✔ hosting[polina-test2]: version finalized
i hosting[polina-test2]: releasing new version...
✔ hosting[polina-test2]: release complete
✔ Deploy complete!
Project Console: https://console.firebase.google.com/project/polina-test2/overview
Hosting URL: https://polina-test2.web.app
Look at this part of your output:
? What do you want to use as your public directory? build/web
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
? Set up automatic builds and deploys with GitHub? No
? File build/web/index.html already exists. Overwrite? Yes
✔ Wrote build/web/index.html
You told it to overwrite the existing build/web/index.html. That's what you're seeing in the browser - the HTML provided by the Firebase CLI.
You will need to make sure your "public directory" (which you set as "build/web") contains what you want to deploy with an index.html to serve by default before you run firebase deploy.
I have successfully compiled my nuxt3 project locally. But the deployment is not working with cloud flare page
00:14:35.140 Executing user command: npm run generate
00:14:35.613
00:14:35.613 > generate
00:14:35.613 > nuxt generate
00:14:35.614
00:14:35.725 Nuxt CLI v3.0.0-rc.3-27567768.c1f728e
00:14:38.919 ✔ Using ~/components/content for components in Markdown
00:14:43.437 ℹ Vite client warmed up in 3072ms
00:14:44.646 ℹ Client built in 4280ms
00:14:44.681 ℹ Building server...
00:14:47.053 ✔ Server built in 2373ms
00:14:47.249 ✔ Generated public dist
00:14:47.249 ℹ Initializing prerenderer
00:14:50.871 ℹ Prerendering 4 initial routes with crawler
00:14:50.891 ├─ / (20ms)
00:14:50.894 ├─ /200 (3ms)
00:14:50.897 ├─ /404 (3ms)
00:14:50.958 ├─ /api/_content/cache (61ms)
00:14:50.971 ✔ You can now deploy .output/public to any static hosting!
00:14:51.017 Finished
00:14:51.018 Note: No functions dir at /functions found. Skipping.
00:14:51.018 Validating asset output directory
00:14:51.018 Error: Output directory ".output/public" not found.
00:14:52.095 Failed: build output directory not found
This is failed with "Error: Output directory ".output/public" not found." but actually the directory is generated few lines before. Any clue to resolve this problem?
I worked around the problem with:
Adding Nitro output config [1] [2] to nuxt.config.ts:
export default defineNuxtConfig({
"nitro": {
"output": {
dir: 'output',
serverDir: 'output/server',
publicDir: 'output/public'
}
}
})
In Cloudflare Pages, setting build output directory to: server/output/public.
I think the issue is caused by the default deployment script at CloudFlare side, checking the existence of .output, but not being able to see "hidden" (starting with dot) folders.
17:27:08.682 Validating asset output directory
17:27:08.682 Error: Output directory ".output/public" not found.
Edit (2022-07-10) found a cleaner way:
add "target" : "static" to nuxt.config.ts
Use as CloudFlare Pages build command: ./node_modules/.bin/nuxt generate
Set CloudFlare Pages build output directory to dist
I also had this issue, after testings, this is what i found.
The documentation says Use the nuxi generate command to build your application. (https://v3.nuxtjs.org/getting-started/deployment#static-hosting).
Configure Node Version
First, i'll add an .nvmrc file at the root of the project, so that Cloudflare doesn't use its default 12.18.0 version on deploy.
The content of the file is :
16
sources:
nuxt 3 prerequisites : https://v3.nuxtjs.org/getting-started/installation/#prerequisites
Node version on Cloudflare Pages : https://developers.cloudflare.com/pages/platform/build-configuration/#language-support-and-tools
Configure the Cloudflare Page
Then i'm adding the configuration in the cloudflare interface with following :
Build command: npx nuxi generate
Build output directory: /.output/public
Root directory: /
🚀
Going further
Actually, it shouldn't be a problem to deploy easily on CF Pages: the team has added a cloudflare_pages preset right into nitro, the server library behind nuxt 3. https://nitro.unjs.io/deploy/providers/cloudflare#cloudflare-pages
I wasn't able to make this preset work for now, i'll update my answer when this has changed :)
I'm trying to use firebase init with package firebase, firebase-admin and firebase-tools. I've downloaded the json file from the firebase console and I've put it on the server, then i run firebase init function. there i choose realtime database and use existing project
but after that function run i get error
Error: HTTP Error: 403, Permission denied to get service [firebasedatabase.googleapis.com]
Help Token: ***this is help token***
here are the details of the results of the firebase init that I did
root#api:/var/www/api/public_html# firebase init
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/var/www/api/public_html
Before we get started, keep in mind:
* You are currently outside your home directory
? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your choices. Realtime Databas
e: Configure a security rules file for Realtime Database and (optionally) provision default instance
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? Please select an option: Use an existing project
? Select a default Firebase project for this directory: api (Api)
i Using project api (Api)
=== Database Setup
i database: ensuring required API firebasedatabase.googleapis.com is enabled...
Error: HTTP Error: 403, Permission denied to get service [firebasedatabase.googleapis.com]
Help Token: ***this is help token***
Check if your service account has the right access rights. Try below.
Follow link
https://console.cloud.google.com/iam-admin/iam?project=api
Find the member that ends with "#appspot.gserviceaccount.com", and click "edit".
Give it "Editor Role", or attach "Firebase Realtime Database Admin".
I'm trying to execute "firebase init functions" as a Firebase admin (not owner) in an existing project but receive the following 403 error:
➜ website git:(master) ✗ firebase init functions
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
/Users/cliff/Work/map/website
Before we get started, keep in mind:
* You are initializing in an existing Firebase project directory
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
i .firebaserc already has a default project, using my-web-project.
=== Functions Setup
A functions directory will be created in your project with a Node.js
package pre-configured. Functions can be deployed with firebase deploy.
Error: HTTP Error: 403, The caller does not have permission
Having trouble? Try firebase [command] --help
➜ website git:(master) ✗
Any suggestions?
Apparently, if you're NOT the Firebase Owner then you need to have an additional permission added by the Owner as follows:
Error: Missing permissions required for functions deploy. You must have permission iam.serviceAccounts.ActAs on service account my-web-project#appspot.gserviceaccount.com.
To address this error, ask a project Owner to assign your account the "Service Account User" role from this URL:
https://console.cloud.google.com/iam-admin/iam?project=my-web-project
Hope this helps someone in the future.
The output is telling you that the CLI has found an existing project called "my-web-project" using a .firebaserc file in the current directory or one of its parent directories. The error is telling you that the Google user account you are logged in as does not have permission to work with that project.
It's not clear what your intent was in running this command, but you will have to either:
create a new directory and a new project to work with
or grant the current user some sort of access to work with the existing project that the CLI found
F:\projects\done>firebase init
######## #### ######## ######## ######## ### ###### ########
## ## ## ## ## ## ## ## ## ## ##
###### ## ######## ###### ######## ######### ###### ######
## ## ## ## ## ## ## ## ## ## ##
## #### ## ## ######## ######## ## ## ###### ########
You're about to initialize a Firebase project in this directory:
F:\projects\done
? Are you ready to proceed? Yes
? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confi
rm your choices. Hosting: Configure and deploy Firebase Hosting sites
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? Please select an option: Use an existing project
? Select a default Firebase project for this directory: angular-fireb (angular-fireb)
i Using project angullar-fireba (angullar-fireba)
=== Hosting Setup
Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.
? What do you want to use as your public directory? dist/done/index.html
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
Error: An unexpected error has occurred.
At the question What do you want to use as your public directory? try answering just dist/done.