0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【エラー解消】Firebase error : failed to get document because the client is offline

Posted at

firebase emulatorとは

  • Firebase
    開発時にFirebaseのサービスを利用するためのプラットフォーム
  • firebase emulator
    Firebaseのサービスをローカルでシミュレーションしてテストを行うためのツール

今回の原因

firebase emulatorをコマンドプロンプトでインストールして起動していた為。

解決策

connectStorageEmulator を明示的にインポートする。

FireBase.js
import { getStorage, connectStorageEmulator } from 'firebase/storage';
import {
  getFirestore,
  getDocs,
  collection,
  connectFirestoreEmulator, // ← 忘れず追加
} from "firebase/firestore";

// 接続コード
if (window.location.hostname === "localhost") {
  console.log("🔥 Connecting to Firebase emulators...");
  connectFirestoreEmulator(db, "localhost", 8080);
  connectStorageEmulator(storage, "localhost", 9199);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?