mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 11:32:39 +00:00
Use a library instead. Checks that the browser is compatible first.
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -3413,6 +3413,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"express-static-gzip": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/express-static-gzip/-/express-static-gzip-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-XGozfjgsfVKBc8lQmPco9zd1+sK9Wy1ZPEAYtH8E34FbBr5BFp2HV+V1PpmIYHaWg8+ecLl/JnQkREbtPSJyxQ==",
|
||||||
|
"requires": {
|
||||||
|
"serve-static": "^1.14.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"extend": {
|
"extend": {
|
||||||
"version": "3.0.2",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
|
||||||
|
|||||||
@@ -49,6 +49,7 @@
|
|||||||
"cookie-parser": "^1.4.5",
|
"cookie-parser": "^1.4.5",
|
||||||
"create-react-class": "^15.6.3",
|
"create-react-class": "^15.6.3",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"express-static-gzip": "2.1.0",
|
||||||
"fs-extra": "9.0.1",
|
"fs-extra": "9.0.1",
|
||||||
"googleapis": "59.0.0",
|
"googleapis": "59.0.0",
|
||||||
"jwt-simple": "^0.5.6",
|
"jwt-simple": "^0.5.6",
|
||||||
|
|||||||
23
server.js
23
server.js
@@ -1,6 +1,7 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const jwt = require('jwt-simple');
|
const jwt = require('jwt-simple');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
const expressStaticGzip = require('express-static-gzip');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
@@ -8,16 +9,20 @@ const homebrewApi = require('./server/homebrew.api.js');
|
|||||||
const GoogleActions = require('./server/googleActions.js');
|
const GoogleActions = require('./server/googleActions.js');
|
||||||
|
|
||||||
// Serve brotli-compressed static files if available
|
// Serve brotli-compressed static files if available
|
||||||
app.get(['*.js', '*.css'], function(req, res, next) {
|
// app.get(['*.js', '*.css'], function(req, res, next) {
|
||||||
if(fs.existsSync(`build${req.url}.br`)){
|
// if(fs.existsSync(`build${req.url}.br`)){
|
||||||
req.url = `${req.url}.br`;
|
// req.url = `${req.url}.br`;
|
||||||
res.set('Content-Encoding', 'br');
|
// res.set('Content-Encoding', 'br');
|
||||||
res.set('Content-Type', 'text/javascript');
|
// }
|
||||||
}
|
// next();
|
||||||
next();
|
// });
|
||||||
});
|
|
||||||
|
|
||||||
app.use(express.static(`${__dirname}/build`));
|
app.use('/', expressStaticGzip(`${__dirname}/build`, {
|
||||||
|
enableBrotli: true,
|
||||||
|
orderPreference: ['br']
|
||||||
|
}));
|
||||||
|
|
||||||
|
//app.use(express.static(`${__dirname}/build`));
|
||||||
app.use(require('body-parser').json({ limit: '25mb' }));
|
app.use(require('body-parser').json({ limit: '25mb' }));
|
||||||
app.use(require('cookie-parser')());
|
app.use(require('cookie-parser')());
|
||||||
app.use(require('./server/forcessl.mw.js'));
|
app.use(require('./server/forcessl.mw.js'));
|
||||||
|
|||||||
Reference in New Issue
Block a user