Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add correct content-type header for gzipped version. #705

Merged
merged 1 commit into from
Jan 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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