Can not take the site live as it wont connect to the database

Im a newbie so go easy!

Ive got the code working perfectly in the preview.

But as soon as i take it to the live url, once logged in, the login says successful, but the code will not load.

Ive taken the a.i suggestion of adding the api keys to src/lib/firebase.ts however it doesnt work.

What do i need to do to emulate the preview to the live url?

Welcome!

Correct me if I’m wrong:

You’re able to login to your app and use it in the preview just fine.

But after you published your app and view it on the hosting domain it does not work as expected. You are able to authenticate and login, but your code doesn’t work once logged in.

Can you open the developer tools with Ctrl+Shift+i and take a screenshot or copy and paste the console?

1 Like

Thank you for your reply.

Thats correct!

Console gives me such errors as this

Failed to load resource: the server responded with a status of 400 ()
933-f939fe81ceb415bc.js:1 [2025-07-02T18:28:54.313Z] @firebase/firestore: Firestore (11.9.0): WebChannelConnection RPC ‘Listen’ stream 0x372e7834 transport errored. Name: undefined Message: undefined
l @ 933-f939fe81ceb415bc.js:1
firestore.googleapis.com/google.firestore.v1.Firestore/Listen/channel?gsessionid=d26M3hE8LMKhqeh0bRvtSBl9dU-ViwhKKVF_DMZjhP0&VER=8&database=projects%2Fweightwise-ai-bswz8%2Fdatabases%2F(default)&RID=rpc&SID=hOzFU0ntxP6EwI5gJtHOCQ&AID=0&CI=0&TYPE=xmlhttp&zx=faq5j4xbbzv&t=1:1

Also, random times throughout the day, the project stops working and the firebase studio project shows me an initialising screen and will not let me in for about 30 minutes.

Which kills the entire point of having a hosted app! Imagine popping that live and having those issues! :frowning:

Firebase Studio has some quirks to it. The VMs it runs on are limited. You will have to go back to the main Firebase Studio menu and restart your VM from time to time and refresh the page.

Your error indicates an issue with Firestore.

Does your app use localStorage or Firestore?
Have you setup ReCAPTCHA?
Is your debug token in the AppCheck → Apps → 3 Dots Menu?
Have you authorized all your domains in your project settings?
Is your Firestore database named (default)?
Do you have firestore.rules configured?

Each of these may take some time to figure out and setup, but they are worth going through one by one and should make sure your app is production ready.

The strange thing is, ive built a quick basic database app and it works liek a dream! Fast never fails! albeit less data, but even this app in question here is not that large at all, its simply 15 fields or so of user data.

Does your app use localStorage or Firestore? Using firestore.
Have you setup ReCAPTCHA? No i havent
Is your debug token in the AppCheck → Apps → 3 Dots Menu?
Have you authorized all your domains in your project settings? yes 100%
Is your Firestore database named (default)? No its not! i had original issues with this, problem is i cant rename it now, although saying that the database only has one entry for testing anyhow, so i could delete this and try adding new data as a new user.
Do you have firestore.rules configured? yes these are configured and look correct.

here is a screenshot

Yeah I had this exact same issue, I had Firestore working at one point with a custom database name, but then it suddenly stopped working and I couldn’t pinpoint the issue.

I eventually had to create the (default) database again in Firestore, export my data from my existing database to a Google Cloud Bucket, import it to (default), then delete my old database and everything worked fine. The export and import process is not too complicated and you can see your data in the Firestore window immediately to confirm.

Try that before anything else.

Bless you for your time to discuss this with me.

Thankfully I have only got myself as a user with one user data entry which is so small!

Even Gemini got stumped! lol

It seems that the ability to name a database just doesn’t quite work.

Im going to try this now.

Of course–Best of luck! :victory_hand:

We have lift off!

Thank you so much!

Now to go through the hopefully easy task of adding stripe and deploying as an app :slight_smile:

1 Like

Awesome.

There’s a Firebase extension for Stripe.

I have installed but I haven’t reached the point of integrating it yet.

Ps. Mark the post as the solution to close out the thread so others know it worked!