Skip to content

Commit 042ffa1

Browse files
arunodarauchg
authored andcommitted
Add correct content-type header for gzipped version. (vercel#705)
1 parent 9163da4 commit 042ffa1

File tree

3 files changed

+153
-150
lines changed

3 files changed

+153
-150
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"is-windows-bash": "1.0.3",
6363
"json-loader": "0.5.4",
6464
"loader-utils": "0.2.16",
65+
"mime-types": "2.1.13",
6566
"minimist": "1.2.0",
6667
"mkdirp-then": "1.2.0",
6768
"mz": "2.6.0",

server/render.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createElement } from 'react'
33
import { renderToString, renderToStaticMarkup } from 'react-dom/server'
44
import send from 'send'
55
import accepts from 'accepts'
6+
import mime from 'mime-types'
67
import requireModule from './require'
78
import resolvePath from './resolve'
89
import readPage from './read-page'
@@ -149,6 +150,8 @@ export async function serveStaticWithGzip (req, res, path) {
149150

150151
try {
151152
const gzipPath = `${path}.gz`
153+
const contentType = mime.lookup(path) || 'application/octet-stream'
154+
res.setHeader('Content-Type', contentType)
152155
res.setHeader('Content-Encoding', 'gzip')
153156
await serveStatic(req, res, gzipPath)
154157
} catch (ex) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy