18
18
import { FirebaseApp } from '@firebase/app-types' ;
19
19
import { safeGet , CONSTANTS } from '@firebase/util' ;
20
20
import { Repo } from './Repo' ;
21
- import { fatal } from './util/util' ;
21
+ import { fatal , log } from './util/util' ;
22
22
import { parseRepoInfo } from './util/libs/parser' ;
23
23
import { validateUrl } from './util/validation' ;
24
24
import './Repo_transaction' ;
@@ -32,9 +32,6 @@ import {
32
32
FirebaseAuthTokenProvider
33
33
} from './AuthTokenProvider' ;
34
34
35
- /** @const {string} */
36
- const DATABASE_URL_OPTION = 'databaseURL' ;
37
-
38
35
/**
39
36
* This variable is also defined in the firebase node.js admin SDK. Before
40
37
* modifying this definition, consult the definition in:
@@ -101,13 +98,17 @@ export class RepoManager {
101
98
authProvider : Provider < FirebaseAuthInternalName > ,
102
99
url ?: string
103
100
) : Database {
104
- let dbUrl : string | undefined = url || app . options [ DATABASE_URL_OPTION ] ;
101
+ let dbUrl : string | undefined = url || app . options . databaseURL ;
105
102
if ( dbUrl === undefined ) {
106
- fatal (
107
- "Can't determine Firebase Database URL. Be sure to include " +
108
- DATABASE_URL_OPTION +
109
- ' option when calling firebase.initializeApp().'
110
- ) ;
103
+ if ( ! app . options . projectId ) {
104
+ fatal (
105
+ "Can't determine Firebase Database URL. Be sure to include " +
106
+ ' a Project ID when calling firebase.initializeApp().'
107
+ ) ;
108
+ }
109
+
110
+ log ( 'Using default host for project ' , app . options . projectId ) ;
111
+ dbUrl = `${ app . options . projectId } -default-rtdb.firebaseio.com` ;
111
112
}
112
113
113
114
let parsedUrl = parseRepoInfo ( dbUrl ) ;
0 commit comments