Angular中Firebase Storage与Functions模拟器未初始化问题求助
Firebase模拟器本地启用异常问题
已成功集成Firestore、Auth、Functions和Storage服务,当前尝试在本地启用Firebase模拟器。调试时发现provideAuth和provideFirestore模块可正常初始化(被调用),但provideStorage和provideFunctions函数完全未触发。推测该问题导致上传文件至Storage时直接发送到生产环境,Functions服务也存在同样的环境指向错误。
相关代码
@NgModule({ declarations: [ AppComponent, DashboardComponent, SignInComponent, SignUpComponent, ForgotPasswordComponent, VerifyEmailComponent ], imports: [ BrowserModule, HttpClientModule, AppRoutingModule, provideFirebaseApp(() => initializeApp(environment.firebase)), provideFunctions(() => { const funcs = getFunctions(); connectFunctionsEmulator(funcs, "127.0.0.1", 5001); return funcs; }), provideStorage(() => { const storage = getStorage(); connectStorageEmulator(storage, "127.0.0.1", 9199); return storage; }), provideAuth(() => { const auth = getAuth(); connectAuthEmulator(auth, "http://localhost:9099", { disableWarnings: true }); return auth; }), provideFirestore(() => { const firestore = getFirestore(); connectFirestoreEmulator(firestore, "localhost", 8080); return firestore; }), provideRemoteConfig(() => getRemoteConfig()), ], providers: [AuthService], bootstrap: [AppComponent] }) export class AppModule { }
开发环境配置
export const environment = { production: false, firebase: { projectId: 'crProject', appId: '1:xxx106x68xxx:web:xxxb3x7d47xxx7dd9c1xxx', databaseURL: 'https://crProject-default-rtdb.europe-west1.firebasedatabase.app', storageBucket: 'crProject.appspot.com', locationId: 'europe-west', apiKey: 'xxzaxxDtCYbgxxxKFxxxxuyLtxxxB3FGxxxqJm8', authDomain: 'crProject.firebaseapp.com', messagingSenderId: '5xx1xx9xx791', measurementId: 'G-xxxZBxHxxx', } };
依赖列表
├── @angular-devkit/build-angular@16.1.0 ├── @angular/animations@16.1.1 ├── @angular/cli@16.1.0 ├── @angular/common@16.1.1 ├── @angular/compiler-cli@16.1.1 ├── @angular/compiler@16.1.1 ├── @angular/core@16.1.1 ├── @angular/fire@7.6.1 ├── @angular/forms@16.1.1 ├── @angular/platform-browser-dynamic@16.1.1 ├── @angular/platform-browser@16.1.1 ├── @angular/router@16.1.1 ├── @types/jasmine@4.3.4 ├── bootstrap@5.3.0 ├── firebase-tools@12.4.0 ├── firebase@9.22.2 ├── jasmine-core@4.6.0 ├── karma-chrome-launcher@3.2.0 ├── karma-coverage@2.2.0 ├── karma-jasmine-html-reporter@2.1.0 ├── karma-jasmine@5.1.0 ├── karma@6.4.2 ├── ngx-spinner@16.0.2 ├── rxjs@7.8.1 ├── tslib@2.5.3 ├── typescript@5.1.3 └── zone.js@0.13.1
内容的提问来源于stack exchange,提问作者mctuna
相关产品推荐
相关产品推荐

