最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - run Firebase locally - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question edited May 22, 2016 at 15:42 Frank van Puffelen 600k85 gold badges889 silver badges859 bronze badges asked May 22, 2016 at 12:47 exoslavexoslav 2,2953 gold badges24 silver badges27 bronze badges 2
  • "but I dont want any "public" dir in my app" Why not? Seems like the simplest solution. – ceejayoz Commented May 22, 2016 at 12:49
  • Just want to keep my file structue as it is. – exoslav Commented May 22, 2016 at 12:57
Add a ment  | 

3 Answers 3

Reset to default 5

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 mand:

firebase login

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

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

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.

发布评论

评论列表(0)

  1. 暂无评论