Use gzip compression and security headers

This commit is contained in:
Jan Tuomi
2018-08-19 14:20:55 +03:00
parent 8d9da98ee5
commit 5839d68397
2 changed files with 7 additions and 0 deletions
+2
View File
@@ -50,12 +50,14 @@
"babel-preset-env": "^1.7.0",
"babel-preset-minify": "^0.4.3",
"babel-preset-react": "^6.24.1",
"compression": "^1.7.3",
"css-loader": "^0.28.11",
"dotenv-webpack": "^1.5.7",
"express": "^4.16.3",
"favicons-webpack-plugin": "0.0.9",
"file-loader": "^1.1.11",
"fs-extra": "^6.0.1",
"helmet": "^3.13.0",
"html-webpack-plugin": "^3.2.0",
"husky": "^1.0.0-rc.9",
"image-webpack-loader": "^4.3.0",
+5
View File
@@ -2,6 +2,8 @@ import * as React from "react";
import * as express from "express";
import { renderToString } from "react-dom/server";
import * as morgan from "morgan";
import * as helmet from "helmet";
import * as compression from "compression";
import App from "./App";
import * as fs from "fs";
@@ -14,6 +16,9 @@ const indexHtml = fs.readFileSync(path.resolve("./dist/index.html"), "utf-8");
const html = body => indexHtml.replace("<div id=\"root\"></div>", `<div id="root">${body}</div>`);
server.use(morgan("short"));
server.use(helmet());
server.use(helmet.hidePoweredBy());
server.use(compression());
server.use("/assets", express.static("dist/assets"));
server.use("/js", express.static("dist/js"));