forked from cioos-siooc/metadata-entry-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebase.js
54 lines (43 loc) · 2.14 KB
/
firebase.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { initializeApp } from 'firebase/app'
// import { getFunctions, connectFunctionsEmulator } from "firebase/functions";
// import "firebase/compat/database";
const deployedOnTestServer = process.env.REACT_APP_DEV_DEPLOYMENT;
const prodConfig = {
// see https://console.cloud.google.com/apis/credentials?project=cioos-metadata-form
// and https://console.cloud.google.com/apis/credentials?project=cioos-metadata-form-dev
// for api key location which is then stored in a github secret and added to several
// github actions to support testing and deployment.
// see https://firebase.google.com/docs/projects/api-keys for a discussion of why we
// don't need to restrict api keys for firebase but might in some situations.
// To prevent the future foot gun, we are restricting the key now.
apiKey: process.env.REACT_APP_GOOGLE_CLOUD_API_KEY,
authDomain: "cioos-metadata-form.firebaseapp.com",
databaseURL: "https://cioos-metadata-form.firebaseio.com",
projectId: "cioos-metadata-form",
storageBucket: "cioos-metadata-form.appspot.com",
messagingSenderId: "646114203434",
appId: "1:646114203434:web:bccceadc5144270f98f053",
};
const devConfig = {
apiKey: process.env.REACT_APP_GOOGLE_CLOUD_API_KEY_DEV,
authDomain: "cioos-metadata-form-dev.firebaseapp.com",
databaseURL: "https://cioos-metadata-form-dev-default-rtdb.firebaseio.com/",
projectId: "cioos-metadata-form-dev",
storageBucket: "cioos-metadata-form-dev.appspot.com",
messagingSenderId: "392401521083",
appId: "1:392401521083:web:45d1539f9d284f446d5c9e",
};
const config = process.env.NODE_ENV === "production" && !deployedOnTestServer
? prodConfig
: devConfig
if (window.location.hostname === "localhost" && deployedOnTestServer) {
config.databaseURL = "http://localhost:9001?ns=cioos-metadata-form"
}
const App = initializeApp(config);
// // uncomment below to use firebase emulator for local development
// if (window.location.hostname === "localhost" && deployedOnTestServer) {
// const functions = getFunctions(App);
// connectFunctionsEmulator(functions, "127.0.0.1", 5001);
// connectFunctionsEmulator(functions, "127.0.0.1", 5002);
// }
export default App;