Add missing static files middleware
This commit is contained in:
parent
d1e23af74b
commit
1e23e7df65
|
@ -0,0 +1,28 @@
|
||||||
|
const staticFiles = require('express').Router();
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
staticFiles.get('/bundle.js', (req, res) => {
|
||||||
|
if (req.acceptsEncodings('gzip')) {
|
||||||
|
res.set('Content-Encoding', 'gzip');
|
||||||
|
res.set('Content-Type', 'text/javascript');
|
||||||
|
res.sendFile(path.join(process.cwd(), '/public/static/bundle.js.gz'));
|
||||||
|
} else {
|
||||||
|
res.sendFile(path.join(process.cwd(), '/public/static/bundle.js'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
staticFiles.get('/bundle.css', (req, res) => {
|
||||||
|
if (req.acceptsEncodings('gzip')) {
|
||||||
|
res.set('Content-Encoding', 'gzip');
|
||||||
|
res.set('Content-Type', 'text/css');
|
||||||
|
res.sendFile(path.join(process.cwd(), '/public/static/bundle.css.gz'));
|
||||||
|
} else {
|
||||||
|
res.sendFile(path.join(process.cwd(), '/public/static/bundle.css'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
staticFiles.get('*.jpg', (req, res) => {
|
||||||
|
res.sendFile(path.join(process.cwd(), '/public/static', req.url))
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = staticFiles;
|
Loading…
Reference in New Issue