1. var express = require('express')
    2. var history = require('connect-history-api-fallback')
    3. var morgan = require('morgan')
    4. var mime = require('mime-types')
    5. var app = express()
    6. app.use(morgan('short'))
    7. app.get('/check', function(req, res) {
    8. console.log('success')
    9. res.send('success')
    10. })
    11. app.use(history())
    12. app.use(
    13. express.static('dist', {
    14. maxAge: '30d', // '1y' oneDay = 86400000
    15. setHeaders: function(res, path) {
    16. if (mime.lookup(path) === 'text/html') {
    17. res.setHeader('Cache-Control', 'public, max-age=0')
    18. }
    19. }
    20. })
    21. )
    22. app.listen(8080, () => {
    23. console.log('app listening on port 8080')
    24. return '0.0.0.0'
    25. })