Fix firebase emulator for storage

This commit is contained in:
MartinBraquet
2026-02-18 17:46:06 +01:00
parent 3a2e932628
commit cad1fd72e3
3 changed files with 16 additions and 3 deletions

View File

@@ -6,6 +6,10 @@
"auth": {
"port": 9099
},
"storage": {
"port": 9199,
"host": "127.0.0.1"
},
"ui": {
"enabled": true,
"port": 4000

View File

@@ -1,11 +1,19 @@
import { getStorage } from 'firebase/storage'
import { getApp, getApps, initializeApp } from 'firebase/app'
import { FIREBASE_CONFIG } from 'common/envs/constants'
import {connectStorageEmulator, getStorage} from 'firebase/storage'
import {getApp, getApps, initializeApp} from 'firebase/app'
import {FIREBASE_CONFIG, IS_FIREBASE_EMULATOR} from 'common/envs/constants'
// Initialize Firebase
export const app = getApps().length ? getApp() : initializeApp(FIREBASE_CONFIG)
// Initialize storage with emulator support
export const storage = getStorage()
export const privateStorage = getStorage(
app,
'gs://' + FIREBASE_CONFIG.privateBucket
)
// Connect to storage emulator if in emulator mode
if (IS_FIREBASE_EMULATOR) {
connectStorageEmulator(storage, '127.0.0.1', 9199)
connectStorageEmulator(privateStorage, '127.0.0.1', 9199)
}

View File

@@ -61,6 +61,7 @@ module.exports = {
{hostname: '*.giphy.com'},
{hostname: 'ui-avatars.com'},
{hostname: 'localhost'},
{hostname: '127.0.0.1'},
],
},
webpack: (config, {dev}) => {