質問編集履歴

4

修正

2020/09/01 12:59

投稿

tomsuma
tomsuma

スコア38

test CHANGED
File without changes
test CHANGED
@@ -306,19 +306,13 @@
306
306
 
307
307
 
308
308
 
309
- import firebase from "firebase/app"
309
+ import firebase from 'firebase/app'
310
-
310
+
311
- import 'firebase/auth' // If you need it
311
+ import 'firebase/auth'
312
-
313
- import 'firebase/firestore' // If you need it
312
+
314
-
315
- import 'firebase/storage' // If you need it
313
+
316
-
317
- import 'firebase/analytics' // If you need it
314
+
318
-
319
-
320
-
321
- export const clientCredentials = {
315
+ const config = {
322
316
 
323
317
  apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
324
318
 
@@ -334,27 +328,21 @@
334
328
 
335
329
  appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
336
330
 
337
- // measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,
338
-
339
- }
331
+ }
340
-
341
-
342
-
332
+
333
+
334
+
343
- // Check that `window` is in scope for the analytics module!
335
+ export default function initFirebase() {
344
-
336
+
345
- if (typeof window !== 'undefined' && !firebase.apps.length) {
337
+ if (!firebase.apps.length) {
346
-
338
+
347
- firebase.initializeApp(clientCredentials)
339
+ firebase.initializeApp(config)
348
-
349
- // To enable analytics. https://firebase.google.com/docs/analytics/get-started
340
+
350
-
351
- if ('measurementId' in clientCredentials) firebase.analytics()
352
-
353
- }
341
+ }
354
-
355
-
356
-
342
+
357
- export default firebase ;
343
+ }
344
+
345
+
358
346
 
359
347
 
360
348
 

3

修正

2020/09/01 12:59

投稿

tomsuma
tomsuma

スコア38

test CHANGED
File without changes
test CHANGED
@@ -378,6 +378,10 @@
378
378
 
379
379
  ```
380
380
 
381
+ initFirebaseをなくした場合,
382
+
381
383
  API key not validと言われます
382
384
 
385
+
386
+
383
387
  ![initFirebaseをなくした場合のエラー](a14156b09f553e768736e109f5520b9d.png)

2

修正

2020/09/01 12:57

投稿

tomsuma
tomsuma

スコア38

test CHANGED
File without changes
test CHANGED
@@ -378,4 +378,6 @@
378
378
 
379
379
  ```
380
380
 
381
+ API key not validと言われます
382
+
381
383
  ![initFirebaseをなくした場合のエラー](a14156b09f553e768736e109f5520b9d.png)

1

修正

2020/09/01 12:56

投稿

tomsuma
tomsuma

スコア38

test CHANGED
File without changes
test CHANGED
@@ -377,3 +377,5 @@
377
377
 
378
378
 
379
379
  ```
380
+
381
+ ![initFirebaseをなくした場合のエラー](a14156b09f553e768736e109f5520b9d.png)