firebase / firebase/firebase-tools

specifying `--config <path>` also loads parts of `firebase.json`

Open
#9,773 3 comments 0 reactions 0 assignees View on GitHub
api: hosting emulator-suite reproducible type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:** 15.2.1

**Platform:** Ubuntu

### [REQUIRED] Test case

I want to have cache headers when deployed to live, but not on dev.
So I've made a `firebase.dev.json` which is a copy of `firebase.json`, but without the `hosting.headers` section.
However, when running `firebase emulators:start --config ./firebase.dev.json` it also seems to load the `firebase.json` because requests are returning the configured headers.
I've verified this by adding the following header

```
{
"source": "/",
"headers": [
{
"key": "WTF",
"value": "is going on?"
}
]
}
```

to `hosting.headers` in `firebase.json`, rebooting the emulators and this header appears (so its not browser caching or anything else mad, its genuinely coming from the `firebase.json`.

So then I made the assumption that it must merge `firebase.json` with whatever your provide to `--config` despite this being undocumented.
So i make a base `firebase.json`, then `firebase.dev.json` is just `{}` and `firebase.prod.json` just has `{hosting: headers: [ ... ] }` in it, but then invoking the emulator with `--config ./firebase.dev.json` complains that all other sections are missing, which they are.

So it isnt merging the whole file, it looks like just the hosting emulator always loads `firebase.json` regardless of `--config` and then applies `---config ` over the top.

Insanity

### [REQUIRED] Steps to reproduce

firebase.json
```
// usual stuff plus:

"headers": [
{
"source": "/",
"headers": [
{
"key": "WTF",
"value": "is going on?"
}
}
```

firebase.dev.json
```
// usual stuff but no "headers"
```

run `firebase emulators:start --config ./firebase.dev.json`

request `localhost:5000/`

observe the presence of the `WTF` header

### [REQUIRED] Expected behavior

`--config` only loads the provided config.json

### [REQUIRED] Actual behavior

Hosting emulator seems to always load at least the headers section from `firebase.json`, havent tested other sections

Theres nothing in the logs of any value, it doesn't print anything to say which config file its loaded except repeating the Command you use to invoke it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.