firebase / firebase/firebase-tools

`firebase serve` doesn't fully imitate Firebase hosting server

Open
#1,665 1 comment 1 reaction 1 assignee Claimed by @bkendall View on GitHub
api: hosting
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:** 7.3.2

**Platform:** Arch Linux

### [REQUIRED] Test case

My `firebase.json` looks like this:

```json
{
"hosting": {
"public": "build",
"rewrites": [{
"source": "!(/assets/**)",
"destination": "/index.html"
}],
"headers": [{
"source": "/assets/**",
"headers": [{
"key": "Cache-Control",
"value": "public, max-age=31536000"
}]
}, {
"source": "!(/assets/**)",
"headers": [{
"key": "Cache-Control",
"value": "no-cache"
}]
}]
}
}
```

`build` directory looks like this:

```
build
├── assets
│   ├── main.js
└── index.html
```

### [REQUIRED] Steps to reproduce

Deploy the site to Firebase and run `$ firebase serve`. Then, compare response status codes, headers and bodies between the two for the following paths:

* `/assets/`
* `/assets/foo`
* `/assets/main.js`

### [REQUIRED] Expected behavior

On Firebase:

* I get status code 404 and the default 404 page is displayed for both `/assets/` and `/assets/foo`.
* `cache-control: public, max-age=31536000` header is set for `/assets/main.js`.

### [REQUIRED] Actual behavior

With `$ firebase serve`:

* Both `/assets/` and `/assets/foo` are internally rewritten to `/index.html` with status code 200.
* `Cache-Control: no-cache` header is set for `/assets/main.js`.

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.