exoslav
exoslav

Reputation: 2295

run Firebase locally

I am new with Firebase and I am struggling with its docs for an 2 hours now, and I can´t figure out how to run my local project with Firebase (Firebase for web).

My app is like:

-- node_modules
-- app
  -- index.html
  -- src
    -- css, js, etc.

Basically I want to run my app from app/index.html. I have installed firebase tools, run firebase init (i am not familiar with all init options) and then run firebase serve.

It throws error "an unexpected error has occurred", probably due to missing public directory (but I don't want any "public" dir in my app).

I have also put firebase app code from my Firebase project to my index.html, but it logs error: Error: Illegal url for new iframe and This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.

Upvotes: 0

Views: 4674

Answers (3)

Hemaka Raveen
Hemaka Raveen

Reputation: 267

When you initiate the firebase configuration if you add https:// with the firebase authDomain, you won't be able to use firebase authentication in localhost because it doesn't contain https. Remove the https:// from the authDomain URL. It'll work.

Upvotes: 0

Blaine Garrett
Blaine Garrett

Reputation: 1366

Double check your authDomain value being passed to the payload for initializeApp(). I had accidentally had a trailing comma at the end by way of the .env file.

Upvotes: 4

Thib
Thib

Reputation: 193

When you init, it creates a file:

firebase.json

that looks like this:

{
  "firebase": "yourProjectName",
  "public": "./someFolder",
  "ignore": []
}

The folder that is being served is the one specified by the public property. So if you want to serve the app folder of your project you just have to replace the string:

  "public": "./app",

This error happens because you didn't authorize operations.

This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console

You have to login via the console using the command:

firebase login

Then, it will open the browser and ask for authorization if I remember correctly.

Upvotes: 5

Related Questions