I am about to release my first app using firebase RDB and once the app goes live I would still like to have access to a database that I can mess with for testing purposes.
Should I create a new database instance and then just modify the config object?
let config = {
apiKey: "apiKey",
authDomain: "newDatabase.firebaseapp.com",
databaseURL: "https://newDatabase.firebaseio.com",
projectId: "newDatabase",
storageBucket: "newDatabase",
messagingSenderId: "123456789"
}
Would this the right way to create a development database?
Copying from the comments above. The question is similar to this
The solution is to have multiple projects as dev, staging and production environments. Official post by Google shows how to achieve this.
Related
I am currently building react application with firebase, i don't recall which location i setup for firestore but according to latest docs of firebase you could change location of firebase realtime database which i am unable to change from their website. Console log:-
#firebase/database: FIREBASE WARNING: Database lives in a different region. Please change your database URL to https://xxxxx-xxxx-default-rtdb.asia-southeast1.firebasedatabase.app (https://xxxxx-xxxx-default-rtdb.firebaseio.com/)
So, whenever i change url on the site and click go nothing works.
Try to set databaseUrl when you initialize the app.
firebase.initializeApp({
apiKey: 'key',
authDomain: 'domain',
projectId: 'id',
storageBucket: 'storage',
messagingSenderId: 'id',
appId: 'id',
databaseURL: 'paste-here-needed-database-url'
});
You can't change a location of a existing database. You would need to migrate it manually to a new one that you setup to the location you want. The migration is very easy. Just export the old database into a json file and import it to the new one. You can read more about it here.
There is no option to change the location of the firebase real-time database.
But there is a way to migrate,
You could create a new instance for the same project. Then you have to select the location that you need when creating the real-time database. After that, you have to export the old database and import it to the new one.
I would like to get data from Firebase. I found some tutorials, but all is using Google Credential ServiceAccount to initialize firebase app. this's is tutorial that i found :
https://medium.com/techwasti/spring-boot-firebase-crud-b0afab27b26e , and else tutorial i found, almost like that too, is using ServiceAccount.
But the problem is i cannot get the ServiceAccount from this firebase because it's from third party. that's mean the owner of firebase don't want to give ServiceAccount.json to me, but they give me firebase config to me, like this :
const firebaseConfig = {
apiKey: "apkey",
authDomain: authdomain",
databaseURL: "databaseurl",
projectId: "projectid",
storageBucket: "storragebucket",
messagingSenderId: "messagesenderid",
appId: "appid",
measurementId: "measurementid"
};
So, how can i initialize this firebase using kotlin in my java springboot aplication?
i had try to find the solution, but not found anything,
I would be glad for any help.
If you want to initialize the Firebase Admin SDK, you will need a service account. There are no alternatives for this.
The config for the front end web app that you're showing here will not work at all. That config is only used for frontend apps that are acting as clients on behalf of the end user.
Taking my first steps with Firebase. Just a few pointers to documents explaining what is going on will help.
I have set up a new firebase web project and connected my dev environment with the firebase sdk. Now when I drop the email-password quickstart into the project it works. (after enabling email/password sign in.)
But wait: This quickstart html file does not contain any configuration that the firebase console tells me to paste:
var config = {
apiKey: "xxx",
authDomain: "xxx.xxx.com",
databaseURL: "https://xxx.xxx.com",
projectId: "xxxx",
storageBucket: "xxx.xxx.com",
messagingSenderId: "xxx"
};
Does the local firebase server add the configuration in the background? When and where do I have to add this configuration to web pages?
If you check line 35 of that quickstart, you'll find this magic include:
<script src="/__/firebase/init.js"></script>
This is an auto-generated file by Firebase Hosting, that contains precisely the code that initializes the connection to the Firebase backend services of your project.
If you'd like to learn more about it, read:
Easier configuration for Firebase on the web
SDK imports and automatic initialization
SDK auto-configuration
I know that I can customize domain name for firebase hosting.
But how can I customize the firebase database, auth and storage domain name?
eg.
authDomain: example.firebaseapp.com => auth.example.com
databaseURL: example.firebaseio.com => db.example.com
storageBucket: example.appspot.com => storage.example.com
I tried to cname the domain (eg cname auth.example.com to example.firebaseapp.com)
but this cause the https://auth.example.com shows the certificate error.
can I resolve that?
Firebase doesn't offer the ability to whitelabel our services under your own domain.
You could choose to proxy all traffic through Hosting + Cloud Functions, but that would be a significant amount of additional work.
What is the need to offer your own custom domain on these services?
Did you also change the firebase script snippet in your code?
<script src="https://www.gstatic.com/firebasejs/4.4.0/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "yourkey",
authDomain: "auth.example.com",
databaseURL: "https://db.example.com",
projectId: "yourid",
storageBucket: "storage.example.com",
messagingSenderId: "id"
};
firebase.initializeApp(config);
</script>
When you sign up to firebase they tell you to place this snippet in your code:
// Initialize Firebase
var config = {
apiKey: "your api key",
authDomain: "domain",
databaseURL: "database url",
storageBucket: "storage bucket",
messagingSenderId: "messaging sender id"
};
firebase.initializeApp(config);
Turns out i want to version it publicly on Github. Is there a way i can use some kind of environment variable or should i just don't version a credentials.js script.
All the information in that snippet is meant to be publicly shared with the users of your web app.
These are not secrets or credentials, but they're identifiers that allow the app code to find the Firebase project on Google's servers.
That said: many teams do not want to check it in to version control system, but instead force each developer to use their own Firebase project for development/testing.