mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
feat: env SERVE_STATIC_QUICK=0 yarn start
restore an older behavior of serving static files with ServeLiveDirectory middleware instead of ServeStaticQuick, in case of issues with streaming files from disk via createReadStream if you do encounter this issue, serving uploaded files with node will likely encounter issues as well, but you can choose to serve them directly with nginx, etc., so i guess it's not beyond hope
This commit is contained in:
parent
3f08b966ef
commit
09fea107f3
@ -22,7 +22,8 @@ const self = {
|
||||
// Allow some config options to be overriden via env vars
|
||||
port: process.env.PORT || config.port,
|
||||
domain: process.env.DOMAIN || config.domain,
|
||||
homeDomain: process.env.HOME_DOMAIN || config.homeDomain
|
||||
homeDomain: process.env.HOME_DOMAIN || config.homeDomain,
|
||||
disableServeStaticQuick: process.env.SERVE_STATIC_QUICK === '0'
|
||||
},
|
||||
scan: {
|
||||
instance: null,
|
||||
|
17
lolisafe.js
17
lolisafe.js
@ -191,17 +191,20 @@ if (config.cacheControl) {
|
||||
})
|
||||
}
|
||||
|
||||
// Init ServeStaticQuick middlewares for static assets
|
||||
// Init serve static middlewares for static assets
|
||||
const ServeStaticClass = utils.conf.disableServeStaticQuick
|
||||
? ServeLiveDirectory
|
||||
: ServeStaticQuick
|
||||
// Static assets in /dist directory
|
||||
const serveStaticQuickDistInstance = new ServeStaticQuick(paths.dist, {
|
||||
const serveStaticDistInstance = new ServeStaticClass(paths.dist, {
|
||||
setHeaders: setHeadersForStaticAssets
|
||||
})
|
||||
safe.use(serveStaticQuickDistInstance.middleware)
|
||||
safe.use(serveStaticDistInstance.middleware)
|
||||
// Static assets in /public directory
|
||||
const serveStaticQuickPublicInstance = new ServeStaticQuick(paths.public, {
|
||||
const serveStaticPublicInstance = new ServeStaticClass(paths.public, {
|
||||
setHeaders: setHeadersForStaticAssets
|
||||
})
|
||||
safe.use(serveStaticQuickPublicInstance.middleware)
|
||||
safe.use(serveStaticPublicInstance.middleware)
|
||||
|
||||
// Routes
|
||||
safe.use(album)
|
||||
@ -313,8 +316,8 @@ safe.use('/api', api)
|
||||
|
||||
// Await all ServeLiveDirectory and ServeStaticQuick instances
|
||||
await Promise.all([
|
||||
serveStaticQuickDistInstance.ready(),
|
||||
serveStaticQuickPublicInstance.ready(),
|
||||
serveStaticDistInstance.ready(),
|
||||
serveStaticPublicInstance.ready(),
|
||||
serveLiveDirectoryCustomPagesInstance.ready()
|
||||
])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user