Commit 042ffa11 authored by Arunoda Susiripala's avatar Arunoda Susiripala Committed by Guillermo Rauch

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

parent 9163da45
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
"is-windows-bash": "1.0.3", "is-windows-bash": "1.0.3",
"json-loader": "0.5.4", "json-loader": "0.5.4",
"loader-utils": "0.2.16", "loader-utils": "0.2.16",
"mime-types": "2.1.13",
"minimist": "1.2.0", "minimist": "1.2.0",
"mkdirp-then": "1.2.0", "mkdirp-then": "1.2.0",
"mz": "2.6.0", "mz": "2.6.0",
......
...@@ -3,6 +3,7 @@ import { createElement } from 'react' ...@@ -3,6 +3,7 @@ import { createElement } from 'react'
import { renderToString, renderToStaticMarkup } from 'react-dom/server' import { renderToString, renderToStaticMarkup } from 'react-dom/server'
import send from 'send' import send from 'send'
import accepts from 'accepts' import accepts from 'accepts'
import mime from 'mime-types'
import requireModule from './require' import requireModule from './require'
import resolvePath from './resolve' import resolvePath from './resolve'
import readPage from './read-page' import readPage from './read-page'
...@@ -149,6 +150,8 @@ export async function serveStaticWithGzip (req, res, path) { ...@@ -149,6 +150,8 @@ export async function serveStaticWithGzip (req, res, path) {
try { try {
const gzipPath = `${path}.gz` const gzipPath = `${path}.gz`
const contentType = mime.lookup(path) || 'application/octet-stream'
res.setHeader('Content-Type', contentType)
res.setHeader('Content-Encoding', 'gzip') res.setHeader('Content-Encoding', 'gzip')
await serveStatic(req, res, gzipPath) await serveStatic(req, res, gzipPath)
} catch (ex) { } catch (ex) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment