Fix serving static files with connect-history-api-fallback

This commit is contained in:
Kevin Thomas
2021-11-11 00:22:41 -08:00
parent ecf6769c38
commit af5049c98e

View File

@@ -18,14 +18,18 @@ const fileStoreOptions = {
require('./boot/db')()
require('./boot/auth')()
app.use(history())
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(cookieParser())
if (process.env.NODE_ENV === 'production') {
app.use(express.static(path.join(__dirname, '../dist')))
}
// Workaround for allowing static files to be served while using connect-history-api-fallback
app.use('/samples', express.static(path.join(__dirname, '../', config.get('Server.sampleUploadPath'))))
app.use(history())
app.use('/samples', express.static(path.join(__dirname, '../', config.get('Server.sampleUploadPath'))))
app.use(session({
store: new FileStore(fileStoreOptions),
secret: config.get('Server.sessionSecret'),