firebase / firebase/firebase-js-sdk
AppHosting Firebase: Need to provide options, when not being deployed to hosting via source. (app/no-options)
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### Operating System
macOS 14.5
### Environment (if applicable)
NextJS 15
### Firebase SDK Version
12.2.1
### Firebase SDK Product(s)
Auth
### Project Tooling
I'm using NextJS with Firebase on app hosting. I'm testing with `firebase emulators:start --only apphosting`
### Detailed Problem Description
I'm trying to use the no-config initialization of Firebase as describe here: https://firebase.google.com/docs/app-hosting/firebase-sdks#initialize-with-no-arguments.
However it always fails during apphosting emulator testing with the error `Firebase: Need to provide options, when not being deployed to hosting via source. (app/no-options)`.
I even tried to specify the configuration during Firebase install (`FIREBASE_WEBAPP_CONFIG="{...}" npm install firebase`) however this also doesn't work. I checked the generated files where the config should be stored and they just look like this:
```javascript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.getDefaultsFromPostinstall = () => (undefined);
```
I guess, instead of `undefined` there should be my configuration.
Why can't NPM get the config during post install?
And how should this normally work because if I understand the manual correctly, it should even work without specifying any config env var during install or does this simply not work with NextJS?
### Steps and code to reproduce issue
```javascript
"use client";
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
import { getFirestore } from "firebase/firestore";
import { getRemoteConfig } from "firebase/remote-config";
import { getStorage } from "firebase/storage";
const firebaseApp = initializeApp();
export const auth = getAuth(firebaseApp);
export const firestore = getFirestore(firebaseApp);
export const remoteConfig = getRemoteConfig(firebaseApp);
export const storage = getStorage(firebaseApp);
```
Contributor guide
Assessment
This issue has not been assessed yet.