Skip to content

Commit

Permalink
Add correct content-type header for gzipped version. (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoda authored and rauchg committed Jan 9, 2017
1 parent 9163da4 commit 042ffa1
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 150 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"is-windows-bash": "1.0.3",
"json-loader": "0.5.4",
"loader-utils": "0.2.16",
"mime-types": "2.1.13",
"minimist": "1.2.0",
"mkdirp-then": "1.2.0",
"mz": "2.6.0",
Expand Down
3 changes: 3 additions & 0 deletions server/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createElement } from 'react'
import { renderToString, renderToStaticMarkup } from 'react-dom/server'
import send from 'send'
import accepts from 'accepts'
import mime from 'mime-types'
import requireModule from './require'
import resolvePath from './resolve'
import readPage from './read-page'
Expand Down Expand Up @@ -149,6 +150,8 @@ export async function serveStaticWithGzip (req, res, path) {

try {
const gzipPath = `${path}.gz`
const contentType = mime.lookup(path) || 'application/octet-stream'
res.setHeader('Content-Type', contentType)
res.setHeader('Content-Encoding', 'gzip')
await serveStatic(req, res, gzipPath)
} catch (ex) {
Expand Down
Loading

0 comments on commit 042ffa1

Please sign in to comment.